0
我在SPA網站上使用了用於UI組件的angularstrap。我有一個模式巫婆我創建它作爲代碼動態例如:如何動態更改angularbootstrap模態的templateUrl?
$scope.modal = $modal(
{ controller: "testCtrl",
show : false,
placement : top
});
,我有幾個按鈕,比如這個:
<button type="button" ng-click="setTemplate(1)" ></button>
<button type="button" ng-click="setTemplate(2)" ></button>
,並在我的控制器我有這樣的功能:
$scope.setTemplate = function (val){
if (val == 1){
$scope.modal.templateUrl ="path/to/firsttemp.html" ;
}else if (val== 2){
$scope.modal.templateUrl ="path/to/secondtemp.html" ;
}
}
現在當我點擊每個按鈕我的模態是空的。