在我的应用程序中,我有一个 ng-switch,在其中一个选项卡中,我有一个带有第二个控制器的 div,如下所示:
<div ng-controller="first">
<div ng-switch on="tab">
<div ng-switch-default></div>
<div ng-switch-when="2">
<div ng-controller="second">
</div>
</div>
</div>
</div>
我正在使用 $scope.$broadcast 与第二个控制器通信,但它在 ng-switch 内部,因此似乎无法正常工作。第一个问题为什么?
当我将第二个控制器从 ngswitch 链中取出时,它可以工作。但是当我更改 $scope.tab 值时,什么也没有发生。它应该再次被 ng-switch 捕获。第二个问题为什么?有人可以帮助我吗?谢谢