Angularjs How do you call a controller method inside a javascript function defined in the html template file?

前端 未结 2 1780
清酒与你
清酒与你 2021-01-16 09:16

I read this link: AngularJS access scope from outside js function and I tried to get access to the controller but I didn\'t setup my index.html like the fiddlejs example.

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 10:18

    You can check below code snippet here we are calling the loginwidget scope function in javascript function.
    
    
    function myFunction(){ angular.element(document.getElementById('parentController')).scope().myFunction(); }

    Note: Here you need to define your function in parentController.

提交回复
热议问题