I have encountered an interesting situation with the directive below. In order for my expressnum
function to work in the template, I had to include the line
scope.expressnum = scope.expressnum();
. It does what I need it to do, but I'm not entirely sure why. I suspect that it might be related to binding or call order issues. I tried searching online for more information, but without success - probably because I am not exactly sure what to look for. If someone could shed some light on why this is necessary and provide a way to eliminate scope.expressnum = scope.expressnum();
while still being able to utilize it in my template, I would really appreciate it.
app.directive('simplyIsolated', function () {
return{
restrict: 'EA',
replace: true,
scope:{
attnum: '@numone'
,bindnum: '=numtwo'
,expressnum: '&sq'
}
,link: function (scope, elem, attr){
scope.expressnum = scope.expressnum();
}
,template:'<div><p> using "@" = {{attnum+attnum}}</p>'+
'<p>using "=" {{bindnum+bindnum}}</p>'+
'<p>using "&" {{expressnum(bindnum)}}</p><br/><p>{{y}}</p>'+
'</div>'
};
});