निर्देश मुझे लगता है कि एक वैकल्पिक "अक्षम" विशेषता की जरूरत है एक अनुरूप संचालन के निर्देश है, और मुझे यकीन है कि अगर यह भी संभव है नहीं कर रहा हूँ।AngularJS में वैकल्पिक अभिव्यक्ति विशेषता
अपने मुख्य नियंत्रक में:
.controller('NavCtrl', ['UserResource','RoleResource'], function(UserResource,RoleResource){
var user = UserResource.getUser();
var roles = RoleResource.getRoles();
UserService.init(user, roles); //????
});
मेरी निर्देश में:
.directive('navItem', function(){
return{
restrict: 'A',
scope: {
text: '@',
href: '@',
id: '@',
disable: '&'
},
controller: function($scope, $element, $attrs){
$scope.disabled = ''; //Not sure I even need a controller here
},
replace: true,
link: function(scope, element, attrs){
scope.$eval(attrs.disable);
},
template: '<li class="{{disabled}}"><a href="{{href}}" id="{{id}}">{{text}}</a></li>'
}
});
मेरी HTML में, मैं इस तरह कुछ करना चाहता हूँ:
<div data-nav-item text="My Text" href="/mytemplate.html" id="idx"
disable="UserService.hasRole('ADMIN,BILLING') && someOtherFn(xxx) || ...">
क्षमा करें, मैं गलती से दबाया ctrl + s .. बेला अपने परिवर्तनों के साथ अद्यतन किया गया।क्या आप कृपया पहेली लिंक अपडेट कर सकते हैं। एक बार फिर से क्षमा। – rajkamal
@rajkamal, पहेली के ऊपर दिए गए लिंक को अभी भी मूल संस्करण में ले जाना चाहिए, भले ही आपने एक नया बचाया हो। लोगों को आपका संस्करण देखने के लिए आपको "बेस" बटन पर भी क्लिक करना होगा, इसलिए कोई नुकसान नहीं हुआ। –
यह वही था जो मुझे चाहिए था। धन्यवाद! – boyceofreason