javascript - When alternative log in three type user add, update,delete button show and hide, how possible in angularjs? -
i want alternative log in 3 type's user add, update, delete button show , hide, how possible in angularjs? i'm trying make system simple possible.
html code:
<div ng-show = "isoperator" class="panel-body"> <input ng-model="isoperator"> </div> <div ng-show = "isadmin" class="panel-body"> <input ng-model="isadmin"> </div> <div ng-show = "issuper" class="panel-body"> <input ng-model="issuper"> </div>
javascript code:
.controller("configctrl" , ["$scope","$rootscope","$location","$http", function($scope,$rootscope,$location, $http){ var operator = $scope.isoperator; $scope.addconfigbtn=true; $scope.addvpnconfigbtn=true; $scope.canconfigbtn=true; $scope.saveconfigbtn=true; $scope.canvpnbtn=true; $scope.savvpnbtn=true; $scope.addunibtn=true; $scope.delunibtn=true; $scope.savunibtn=true; $scope.addnnibtn=true; $scope.delnnibtn=true; $scope.savnnibtn=true; $scope.addroutebtn=true; $scope.delroutebtn=true; $scope.saveroutebtn=true; $scope.addlebroutebtn=true; $scope.dellebroutebtn=true; $scope.savelebroutebtn=true; if(operator = $scope.isoperator){ $scope.isoperator=true; $scope.addconfigbtn=false; $scope.addvpnconfigbtn=false; $scope.canconfigbtn=false; $scope.saveconfigbtn=false; $scope.canvpnbtn=false; $scope.savvpnbtn=false; $scope.addunibtn=false; $scope.delunibtn=false; $scope.savunibtn=false; $scope.addnnibtn=false; $scope.delnnibtn=false; $scope.savnnibtn=false; $scope.addroutebtn=false; $scope.delroutebtn=false; $scope.saveroutebtn=false; $scope.addlebroutebtn=false; $scope.dellebroutebtn=false; $scope.savelebroutebtn=false; }else{ $scope.isadmin=false; $scope.issuper=false; } if($scope.isadmin){ $scope.isadmin=true; $scope.addconfigbtn=true; $scope.addvpnconfigbtn=true; $scope.canconfigbtn=true; $scope.saveconfigbtn=true; $scope.canvpnbtn=true; $scope.savvpnbtn=true; $scope.addunibtn=true; $scope.delunibtn=false; $scope.savunibtn=true; $scope.addnnibtn=true; $scope.delnnibtn=false; $scope.savnnibtn=true; $scope.addroutebtn=true; $scope.delroutebtn=false; $scope.saveroutebtn=true; $scope.addlebroutebtn=true; $scope.addlebroutebtn=true; $scope.dellebroutebtn=false; $scope.savelebroutebtn=true; } else{ $scope.isoperator=false; $scope.issuper=false; } if($scope.issuper){ $scope.issuper=true; $scope.addconfigbtn=true; $scope.addvpnconfigbtn=true; $scope.canconfigbtn=true; $scope.saveconfigbtn=true; $scope.canvpnbtn=true; $scope.savvpnbtn=true; $scope.addunibtn=true; $scope.delunibtn=true; $scope.savunibtn=true; $scope.addnnibtn=true; $scope.delnnibtn=true; $scope.savnnibtn=true; $scope.addroutebtn=true; $scope.delroutebtn=true; $scope.saveroutebtn=true; $scope.addlebroutebtn=true; $scope.addlebroutebtn=true; $scope.dellebroutebtn=true; $scope.savelebroutebtn=true; } else{ $scope.isoperator=false; $scope.isadmin=false; }
in order show or hide html tag in angular, can use directives ng-show
, ng-hide
.
e.g.
<input type="button" value="save" ng-show="savelebroutebtn" />
here, used 1 of variable defined in $scope
. on basis of have in $scope.savelebroutebtn
, control shown on html page. if variable not defined on current $scope
, considers false
, hides button.
to know more abot ng-show
, ng-hide
, follow link
Comments
Post a Comment