javascript - ng-attr not changing to true -


i have input looks this:

<input  type="text" autocomplete="off" name="itemcode" ng-model="item.itemcode" class="form-control" ng-attr-existing-item-validator="mode=='add'" required> 

which called existing-item-validator directive if mode not equal 'add', tried

<input  type="text" autocomplete="off" name="itemcode" ng-model="item.itemcode" class="form-control" ng-attr-existing-item-validator="isaddmode()" required> 

however, isaddmode never executed on scope. if change input ng-attr-existing-item-validator="{{isaddmode()}}" execute, existing-item-validator directive still getting called though isaddmode() returning false.

am doing wrong ng-attr attribute? expect directive not called if equal false.

setting directive parameter false doesn't mean directive not created, means passing variable directive can retrieved scope or attr.

while i'm not sure if can activate directive dynamically, can handle behavior in directive (e.g. turning off itself) when according parameter.

.directive('existingitemvalidator', function(){   return function (scope, element, attr) {     if (attr.existingitemvalidator === false) return;      // continue other ops.   } }); 

note: if using attr, need use {{}} pass parameter


Comments

Popular posts from this blog

Hard vs. Soft Water: What's The Difference?

Weed, Guns & Minimum Wage: What Else Is The U.S. Voting On?

The Ten Most Livable Cities In The World