I'm trying to implement an AngularJS directive that takes attribute-flag selected, which indicates initial state + any current value, if it is assignable.
How can I implement a verification in AngularJS directive to see that the attribute is assignable, before setting a 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 is assignable */) {
scope.selected = /* some value */;
}
}
};
}]);