Directive usage
<my-directive my-attr='StackOverflow'></my-directive>
Directive definiton
app.directive('myDirective', function($scope){
return {
restrict: 'E',
template: 'I want to print the attribute value',
controller: function($scope){
// I also want to access the attribute value here.
}
};
});
Is there a way to achieve this.
Instead of scope: true
write,
scope: {
myattr: '@'
}
Then myattr
will be available in $scope
Make sure to use small casing, somehow using any other casing like pascal or camel causes problems.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments