How To Hide A Link By Using Id's?
In my application I'm hiding some links by using Ids. While loading pages a DB call will go and pick all Ids. Ids are nothing but Ids in the below sample code.
<divng-app="myApp"><divng-controller="testController"><ulid="menu-content"><li><ahref="HomePage"ng-hide="menuState.homeId"><spring:messagecode="label.home"/></a></li><li><ahref="loginPage"ng-hide="menuState.loginPageId"><spring:messagecode="label.login" /></a></li><li><ahref="define"ng-hide="menuState.defineId"><spring:messagecode="label.define" /></a></li></ul><buttonng-click="toggleMenuItem('homeId')">Toggle menu entry 1</button><buttonng-click="toggleMenuItem('loginPageId')">Toggle menu entry 2</button><buttonng-click="toggleMenuItem('defineId')">Toggle menu entry 3</button></div></div>
AngularJS App / Controller
var myApp = angular.module('myApp',[]);
myApp.controller('testController', ['$scope', function($scope) {
$scope.menuState = {
homeId: false,
loginPageId: false,
defineId: false,
};
$scope.toggleMenuItem = function (menuId) {
if (angular.isDefined($scope.menuState[menuId])) {
$scope.menuState[menuId] = !$scope.menuState[menuId];
}
}
}]);
Post a Comment for "How To Hide A Link By Using Id's?"