2013-05-13 60 views
2

我有一个角度UI引导的模态。因为我有很多不同的表单,我想在模态中显示,所以我在模态中使用ng-include指令。 src属性动态变化。AngularJS多次打开模态对话框创建额外的示波器

我看到batarang以下行为(即使是静态Src在NG-包括):

每次打开模式,创建一个额外的范围! 因为这个模式会被打开和关闭很多次,我会得到几十个新的范围,并且应用程序变得很慢。

的index.html

<body ng-controller="MainCtrl"> 
    <p><button class="btn" ng-click="showModal()">show Form</button></p> 

    <div class="modal" modal="theModal" close="closeModal()"> 
    <div ng-include src="'form1.html'"></div> 
    </div> 
</body> 

app.js相当primitiv:

app.controller('MainCtrl', function($scope) { 
    $scope.showModal = function() { 
    $scope.theModal = true; 
    }; 

    $scope.closeModal =function(){ 
    $scope.theModal = false; 
    }; 
}); 
+0

这里是[plnkr run](http://run.plnkr.co/plunks/Mbo9OaKA8MFJptwmI3PN/)或[plnkr edit](http://plnkr.co/edit/Mbo9OaKA8MFJptwm I3PN) – kwrl 2013-05-16 11:17:22

回答