Why doesn't ng-click work in my directive and how do I add a toggle class?

后端 未结 3 2020
清酒与你
清酒与你 2021-01-15 15:47

I\'ve created a directive in Angular that looks like this:

angular.module(\'msfApp\')
    .directive(\'listitem\', function () {
        return {
                    


        
3条回答
  •  一个人的身影
    2021-01-15 16:24

    This is happening because you are using isolated scopes in the directive using scope: { 'item': '=' } which creates a new scope so your ng-click is not able to bind to controller function.

    Kindly refer to below link to call parent function using ng-click

    calling method of parent controller from a directive in AngularJS

提交回复
热议问题