Skip to content

Instantly share code, notes, and snippets.

@mizrael
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizrael/055f28364989135e48ed to your computer and use it in GitHub Desktop.
Save mizrael/055f28364989135e48ed to your computer and use it in GitHub Desktop.
AngularJS directive with function (no arguments)
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();
}
};
}]
}
})
<callback-directive callback="myCallback()" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment