JSFiddle - React, Tailwind, and code Playground
by andrew rowe
HTML
<div ng-controller="myCtrl as VM">
<a my-dir attr1="VM.sayHi('Juan')" attr2="VM.sayHi('Juan')" attr3="VM.sayHi('Juan')"></a>
</div>
JavaScript
var myApp = angular.module("myApp", [])
.controller("myCtrl", [function() {
this.sayHi = function(name) {
return ("Hey there, " + name);
}
}])
.directive("myDir", [function() {
return {
scope: {
attr1: "=",
attr2: "@",
attr3: "&"
},
link: function(scope) {
alert(scope.attr1); // logs "Hey there, Juan"
alert(scope.attr2); // logs "VM.sayHi('Juan')"
alert(scope.attr3); // logs "function (a){return h(c,a)}"
alert(scope.attr3()); // logs "Hey there, Juan"
}
}
}]);