Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IIF in JavaScript
Message
 
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01605133
Message ID:
01605252
Views:
28
>>>Glad you got it working. I owe you an apology - seems that binding a property in an isolated scope of a directive is a special case.
>>>The correct syntax is :
>>>The attribute value on the markup for the directive should be the *name* of the property in the scope where it is used.
>>>In the isolated scope you bind to the attribute name (converting snake to camel)
>>>So:
Controller on the element where the directive is used:
>>>$scope.disableClearMessage = true;
>>>// Directive attribute:
>>>disable-action = "disableClearMessage"
>>>// Directive scope:
>>>disableAction : '='
>>>//Directive template:
>>>ng-disabled = "{{disableAction}}"
>>>
>>>Hope that clears it up :-}
>>
>>In my case the template is
>>
>>
>>template: '<a ng-click="click()" ng-disabled="disableAction" >{{ linkText }}</a>'
>>
>>Yet is seems to be working correctly - it is enabled when it should be enabled and disabled when it should be disabled.
>
>Interesting. I tried it with both. Resulting markup:
//When disableClearMessage = true:
>
>//With disableAction:
><a  ng-disabled="disableAction" class="ng-binding" disabled="disabled"></a>
>
>//With {{disableAction}}
><a  ng-disabled="true" class="ng-binding" disabled="disabled"></a>
>
>//When disableClearMessage = false:
>
>//With disableAction:
><a  ng-disabled="disableAction" class="ng-binding"></a>
>
>//With {{disableAction}} :
><a  ng-disabled="false" class="ng-binding"></a>
So both worked but using the curly braces seems more like the desired result (e.g. ng-disabled="true")

I am just afraid it may break code in other places if I adjust it to use {{}}. Since it's working as is right now (although the second case seems better) I'll leave it for now as is.

Thanks again.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform