Same problem as here: AngularJS directive linking a function with multiple arguments
After this answer: stack overflow
In any case, as far as possible.
It works:
<my-directive on-save="ctrl.saveFn"></my-directive>
FROM
angular.module('app') .controller('MyController', function($scope) { var vm = this; vm.saveFn = function(value) { vm.doSomethingWithValue(value); } });
But when I convert to Typescript and use real classes, it breaks.
class MyController { constructor() {} saveFn(value) { this.doSomethingWithValue(value); } }
In Typescript version, when debugging, "this" refers to a global window. So my area is somehow messed up, but I donβt know how to fix it. How can I get "this" for a link to MyController, as expected?
angularjs typescript angularjs-directive
Justin Boyson Aug 04 '16 at 21:44 2016-08-04 21:44
source share