Last active
October 6, 2021 09:37
-
-
Save MasterHans/9fb1a4f2fe48682e49f4c101eb3326b6 to your computer and use it in GitHub Desktop.
AngularJS - pass parameters out from the Custom Directory
This file contains hidden or 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
//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