Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MasterHans/9fb1a4f2fe48682e49f4c101eb3326b6 to your computer and use it in GitHub Desktop.
Save MasterHans/9fb1a4f2fe48682e49f4c101eb3326b6 to your computer and use it in GitHub Desktop.
AngularJS - pass parameters out from the Custom Directory
//Controller
angular.module('b1').controller('WarehousePurchaseEdit', function (){
c.onPurchaseDateChange = function (param) {
alert(param);
}
}
//View
<div ext-on-changes purchase="c.model" handler="c.onPurchaseDateChange"></div>
//Directory
angular.module('b1').directive("extOnChanges", function ($translate) {
return {
scope: {
purchase: '=',
handler: '&'
},
template: 'Current date: {{purchase.purchaseDate}}, current warehouse: {{purchase.warehouseName}}' +
'<button ng-click="s.clickFromDirective()">Call Controller function</button> ',
controllerAs: 's',
controller: function ($scope) {
var s = this;
s.clickFromDirective = function (){
$scope.handler()($scope.purchase.purchaseDate);
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment