2013-05-13 57 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

回答