我想,最好是
$watch你的模型,ng-show绑定。
原文链接:https://www.f2er.com/angularjs/145392.html这里是例子:
<div ng-app="myApp" ng-controller="myCtrl" ng-init="isDisplayed = true"> <div ng-show="isDisplayed">something</div> <button ng-click="isDisplayed = !isDisplayed">Toggle</button> </div> var myApp = angular.module('myApp',[]) .controller('myCtrl',function($scope,$log) { $scope.$watch('isDisplayed',function(newValue,oldValue) { if (newValue !== oldValue) { $log.log('Changed!'); } }); });