Tuesday, April 15, 2014

Directives



namer.js:


index.html: here in this file we are injecting the above namer.js module, that namer module contains the namer directive, here directive use as a class.


Note: above namer.js file

angular.module("namer",[])
.directive("namer",function(){
return{
scope:true,  // used to isolate the scope otherwise if we reuse the namer directive we get the same output all times chk without this once
restrict:"E",  // here we may pass A or C or E as we like even with combination too like "EA"
link:function(scope,element,attribute){
scope.fullName=attribute.first+''+attribute.last;
scope.first=attribute.first;
scope.last=attribute.last;
},
template:"{{first}},{{last}}",
replace:true or false,  // to replace the custopm directive tag or not
}
});








No comments:

Post a Comment