我有一个HTML文件。在该文件,我有一个按钮时应打开模态时。
<button ng-click="open(value.Reservation.id)" class="btn btn-default btn-xs" ></button>
和下面的按钮下方,在同一HTML文件中,我有脚本。
<script type="text/ng-template" id="myModalContent.html">test</script>
和pendendController.js文件,
myApp.controller('PendingCtrl', function ($rootScope, $scope, $location, $http, $modal, $log) {
$scope.open = function (id) {
//GET RESERVATION
$http({method: 'GET', url: 'admin/getUpdateReservation/'+ id +'.json'}).
success(function(data, status, headers, config) {
$scope.post = data.data;
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'UpdateReservationCtrl',
resolve: {
data: function () {
$scope.post.status = $scope.status;
$scope.post.locations = $scope.locations;
return $scope.post;
}
}
});
modalInstance.result.then(function (selectedItem) {
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
}).
error(function(data, status, headers, config) {
alert('error');
});
};
}(
我有updatereservationcontroller.js文件。
hansApp.controller('UpdateReservationCtrl', function ($rootScope, $scope, $route, $http, $modalInstance, data) {
console.log('6');
})
console.log('6'(;作品。但是我看不到模式页面...如何使我的模态起作用?
所以首先,如果您不付出诺言,请不要使用解决方案...
文档对Resolve密钥说了什么:
包含依赖项的对象,这些依赖项将被注入 当所有依赖项都解决时,控制器的构造函数。这 如果拒绝承诺,控制器将不会加载。
看起来您正在使用AngularStarp的模态(如果我错了,请纠正我(。
正如他们在文档中提到的那样,您必须做这样的事情:
modal = $modal({
controller: function($scope) {},
show: false,
});
在您的成功挑战中:
modal.$promise.then(modal.show);