For example, there is an ordinary module with a component.

class TestCtrl { funct() { this.message(); } } Angular.module('app', []) .run(function($rootScope) { $rootScope.message = function() { console.log("test call!"); } }) .component('test', { bindings: { message: '&' }, controller:TestCtrl }) <test message="message" ng-click="$ctrl.funct()"></test> 

It does not start when clicking on an element, there is no reaction whatsoever, what am I doing wrong?

    1 answer 1

    My mistake was that I used a function with arguments. In general, the answer is banal. To buy an angular function with arguments to a directive or component, you need to return a function. Like this

      $rootScope.message = function(arg, arg2) { console.log("test call!"); }; изменить на $rootScope.message = function() { return function(arg, arg2) { console.log("test call!"); } }; Тогда в html, мы выполняем ее, не передавая аргументов и тогда будет возможность делать вызов с любым множеством аргументов. <test message="message()"></test> app.component('test', { bindings: { message: '&' }, controller:function() { $onInit() { this.message(some, some2); // исполняем функцию } } })