Hey,
I have directive (with own controller) within other controler like this:
<div id="Test-content" ng-controller="testCtrl">
<oa-modal-dialog dialog-title="This is example dialog" dialog-state="true" dialog-on-open="" dialog-on-close="test.close()" dialog-type="warning" dialog-size="small" dialog-top-toolbar="" dialog-bottom-toolbar=""></oa-modal-dialog>
</div>
Test controller:
.controller('testCtrl', ['$scope', function ($scope) {
$scope.test = {
close: function() {
console.log('test');
}
};
}])
Modal dialog directive:
.directive('oaModalDialog', function () {
return {
restrict: 'E',
transclude: true,
link: function(scope, element, attrs) {
attrs.$observe('dialogState', function (value) {
scope.dialogState = value;
});
},
templateUrl: 'oaModalDialogs.html',
controller: 'modalDialogsCtrl'
}
});
Question how can I retrieve and fire function which is in directives attribute 'dialog-on-close' in directives controller 'modalDialogs'? Presume that any function can be included into attribute so I can't use fixed function ($scope.test.close() in the controller)
I tried something like this:
.controller('modalDialogsCtrl', ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
$attrs['dialogOnClose']();
}]);
Throws error... Any suggestions?