Last active
August 29, 2015 14:23
-
-
Save mizrael/055f28364989135e48ed to your computer and use it in GitHub Desktop.
AngularJS directive with function (no arguments)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myApp.directive('callbackDirective', function () { | |
return { | |
scope: { | |
callback: '&' | |
}, | |
restrict: 'E', | |
templateUrl: 'my-template.html' | |
controller: ['$scope', function ($scope) { | |
$scope.foo = function () { | |
if ($scope.callback) { | |
$scope.callback(); | |
} | |
}; | |
}] | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<callback-directive callback="myCallback()" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment