:莫代爾,如何動態地關閉彈出模態(UI自舉),而點擊事件Angularjs
<script type="text/ng-template" id="create.html">
<div ng-controller="CreateCampaignCtrl" id="createModal">
<div class="modal-header">
heading
</div>
<div class="modal-body">
----
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" ng-click="cancel()">Close</button>
<button type="button" class="btn btn-primary" ng-click="submit_form()"><i class="fa fa-plus"></i>create method</button>
</div>
</div>
:控制器
function CreateCampaignCtrl($scope, $http){
$scope.submit_form = function(){
$http({
url: url,
data: {},
method: "POST",
headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
}).success(function(data){
$('#createModal').modal('hide');
alert(data);
}).error(function(err) { alert('ERROR err');})
}
};
};
上面的模式是在點擊按鈕時打開ajax請求,現在我想在從服務器獲得響應後動態關閉此模式。
爲什麼不試試'角度控制器代碼中的'$ modalInstanse.close()'? –
你好Pankaj,我嘗試過使用這種方法,但它不工作。感謝您的答覆。 –
你使用'angular-ui-bootstrap'/jQuery'bootstrap'模式嗎? –