below is my directive,
app.directive('search', function($rootScope, $timeout, dynamicValues) {
return {
scope: {
myname: '=',
},
restrict: 'AE',
replace: true,
templateUrl: 'app/partials/template.html',
};
}));
and below is my template.html
<input type="text" name="Name" myname = "maho">
so my requirement is I need to get the value of myname attribute i.e "maho" in my directive I tried it using Attr as below
scope.variable = iAttrs.myname;
alert("myname value is..." + scope.variable);
but I am getting undefined value please suggest me how to do this.
Try this:
app.directive('search', function() {
return {
restrict: 'AE',
replace: true,
templateUrl: 'template.html',
link: function(scope, elm, attrs) {
scope.variable = attrs.myname;
}
};
});
Isolate scopes are for passing variables from parent directives. ngModel binds an element's value to a scope variable.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments