mercredi 26 mars 2014

Why do I need scope.property = scope.property() for expression to work?


Vote count:

0




I have the below directive and in order for my expressnum function to evaluate in my template I need to use scope.expressnum = scope.expressnum();. It works but I don't know why. I thought maybe it might be something to do with binding or call order and I tried googling but can't seem to find anything, most likely because I don't really know what to look for. If someone could explain this to me and how I could possibly leave out scope.expressnum = scope.expressnum(); and still be able to use it in my template I would greatly 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>'

};

});


asked 52 secs ago






Aucun commentaire:

Enregistrer un commentaire