JSFiddle - React, Tailwind, and code Playground
by Matthew Day
HTML
<div ng-app="dr" ng-controller="testCtrl">
<test color1="color1" update-fn="updateFn(msg)"></test>
</div>
JavaScript
var app = angular.module('dr', []);
app.controller("testCtrl", function($scope) {
function myFunc() {
var resd = 'Heytheres';
return resd;
}
$scope.color1 = myFunc();
$scope.updateFn = function(msg) {
alert(msg);
}
});
app.directive('test', function() {
return {
restrict: 'E',
scope: {
color1: '=',
updateFn: '&'
},
template: "<button ng-click='updateFn({msg:\"Hello World!\"})'>{{color1}}</button>",
replace: true,
link: function(scope, elm, attrs) {
}
}
});