javascript - AngularJS directive: Check if attribute is assignable -


i'm trying implement angularjs directive takes attribute-flag selected, indicates initial state + current value, if assignable.

how can implement verification in angularjs directive see attribute assignable, before setting value in it?

app.directive('customcontrol', [function () {     return {         restrict: 'e',         scope: {             selected: '=?', // optional, initial + current selected state;         },         templateurl: 'views/directives/customcontrol.html',         link: function (scope, elem, attr) {             if (/* scope.selected assignable */) {                 scope.selected = /* value */;             }         }     }; }]); 

you use $parse service that:

link: function(scope){     var selectedget = $parse(attrs.selected);     var selectedset = selectedget.assign;      // etc...      if (selectedset){       selectedset(scope.$parent, obj);     } } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -