I am new to angularjs and I don't know if this is possible and if possible how to implement it. I want to create a custom directive with a controller that uses the information passed to it through attributes. This is a broken example of what I want to implement:
HTML should look like this:
<div ng-app="test"> <custom-directive attr1="value1" attr2="value2"></custom-directive> </div>
And js:
var app = angular.module('test', [ ]); app.directive("customDirective", function(){ return { restrict: 'E', scope: ???, controller: function(){ console.log("print attributes value: " + attr1 + ", " + attr2 ); } } }; });
And the expected console output should be:
print attribute value: value1, value2
Any idea? Thanks!
javascript angularjs angularjs-scope angularjs-directive
narcispr
source share