我想显示一个灯箱,其内容由ng-show显示,但是我不知道如何触发灯箱JS。我正在寻找类似的东西
ng-on-show="showLightbox()"
我认为,最好监视绑定ng- show的模型。
这是示例:
<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!'); } }); });
和小提琴