当模式窗口打开时,我试图将一些模型数据传递到模式窗口中。它有成功的$http.post,也有失败的then(),有一些不同的标题和按钮文本。我将多个数据传递给它,如下所示:
//.then(){...//same as below }
,function (response){
$scope.PostRespData = response.data.message || 'Rq Failed';
$scope.pn = $scope.PostRespData.substring(53,63);
//(status=400) response modal string
$scope.name = 'Hey there!';
//modal options
$scope.opts = {
backdrop: true,
backdropClick: true,
dialogFade: false,
keyboard: true,
templateUrl : 'alreadyexists.html',
controller : ModalInstanceCtrl,
resolve: {}
};
$scope.opts.resolve.item = function() {
return angular.copy({name:$scope.name, errmsg:$scope.PostRespData, num:$scope.pn}); // pass name to modal dialo
}
//open the modal and create a modal Isntance
var modalInstance = $uibModal.open($scope.opts);
var ModalInstanceCtrl = function($scope, $uibModalInstance, $uibModal, item) {
$scope.item = item;
$scope.ok = function () {
$uibModalInstance.close();
};
$scope.cancel = function () {
$uibModalInstance.close();
}我的HTML模板如下所示
<div class="modal-header">
<h1>{{item.name}}</h1>
</div>
<div ng-controller="Nav" class="modal-body">
<p>{{item.errmsg}}
<a href="http://myserver.com/page.jsp?num="+{{item.num}}+"&c=y">View {{item.num}}</a>
</p>
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">Edit Current Details</button>
<button class="btn btn-warning" ng-click="cancel()">Edit {{item.num}}</button>
</div>我得到了我的模型,我也得到了静态数据,但传递给它的数据并没有反映出来。我花了一整天的时间试着把它做好。
编辑:添加当前输出图片。

请帮帮我!
发布于 2016-09-16 04:54:57
正如@charlietfl所指出的,这是一个悬而未决的问题。要使用上面的代码,将var ModalInstanceCtrl = func..移到按钮的$http的ng-click调用之外。
https://stackoverflow.com/questions/39518406
复制相似问题