AngularJS - Run function of child controller from parent controller

前端 未结 1 1544
长发绾君心
长发绾君心 2021-01-29 03:39

I have read many questions on this but still can\'t find solution that will be clean and reusable enough.

What I tried and don\'t want to use:

  • Events - $em
1条回答
  •  抹茶落季
    2021-01-29 03:44

    One approach is to use the new ngRef directive:

    
    
    

    Then use it in the controller:

    function startFirstTimer() {
        /* How to run start() function of TimerController here? */
        ctrl.timerOne.start();
    }
    

    The ngRef directive was introduced as a new feature with AngularJS V1.7.1.

    For more information, see AngularJS ng-ref Directive API Reference.

    0 讨论(0)
提交回复
热议问题