AngularJS: ng-if not working in combination with ng-click?

后端 未结 3 2127
长情又很酷
长情又很酷 2020-12-01 06:32

Given this test case using AngularJS 1.2 rc3: http://plnkr.co/edit/MX6otx (repeated below)

1.

  • ng-if toggle
  • 3条回答
    •  生来不讨喜
      2020-12-01 06:38

      Since ngIf creates own scope, to make it work you can define toggle1 in one scope:

      JS**

      $scope.toggleMe = function(){
           $scope.toggle1 = !$scope.toggle1;
          }
      

      HTML

    • ng-if toggle1: {{ toggle1 }}

      does not work

    • See Demo Plunker

    提交回复
    热议问题