我添加了angularjs指令,但它在应用启动时没有运行。 调试控制台中没有打印调试。
html代码:
<li has-role="ROLE_ADMIN" class="dropdown pointer"></li>
angularjs指令:
angular.module('myApp').directive('hasRole', function (){
return {
restrict: 'A',
link: function (scope, element, attrs) {
var setVisible = function () {
console.log('hasAnyRole, setVisible');
element.removeClass('hidden');
},
setHidden = function () {
console.log('hasAnyRole, setHidden');
element.addClass('hidden');
},
defineVisibility = function (reset) {
console.log('hasAnyRole, defineVisibility');
// other logic here...
setVisible();
},
role = attrs.hasRole.replace(/\s+/g, '');
//if (roles.length > 0) {
defineVisibility(true);
//}
}
};
});