Hi there I have this \"confirmable\" button directive which I am working on,
The html code that will trigger the directive \'confirmable\'
It sounds to me like you want to call a method from a parent scope from within your directive...
I've put together a Plunk here
(Sorry, I like JavaScript... so here goes)
Here's you're parent controller.
app.controller('ParentCtrl', function($scope) {
$scope.fooCalled = 0;
$scope.foo = function() {
$scope.fooCalled++;
};
});
Then your mark up
Foo Called: {{fooCalled}}
And your directive declaration:
app.directive('customControl', function(){
return {
restrict: 'E',
scope: {
innerFoo: '&customClick'
},
template: ''
};
});
The bit in the scope
declaration in your directive definition is what ties the parent scope function reference to your directive's scope so it can be called on click. That's what the &
is for there.