AngularJS Material mdDialog 和未处理的承诺拒绝
AngularJS Material mdDialog and unhandled rejection on a promise
我不知道为什么,但我在 hide/cancel
上收到 AngularJS Material mdDialog
的 unhandled rejection
错误
mdDialog
的代码:
$scope.addAttendee = function(ev) {
$mdDialog.show({
controller: DialogController,
templateUrl: 'views/regForm.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
controllerAs: 'ctrl',
fullscreen: $scope.customFullscreen, // Only for -xs, -sm breakpoints.
locals: {parent: $scope}
})
.then(function(response){
if(angular.isDefined(response)){
attendees.push(response);
}
console.log(attendees);
console.log(attendees.length);
})
当我删除承诺时,对话框可以关闭 w/o 错误消息。
知道这是怎么回事吗?
当 mdDiaglog
.
的承诺没有变化时(hide/cancel)我需要一个函数
更新后的代码
$scope.addAttendee = function(ev) {
$mdDialog.show({
controller: DialogController,
templateUrl: 'views/regForm.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
controllerAs: 'ctrl',
fullscreen: $scope.customFullscreen, // Only for -xs, -sm breakpoints.
locals: {parent: $scope}
})
.then(
function(response){
if(angular.isDefined(response)){
attendees.push(response);
console.log(attendees);
console.log(attendees.length);
}
},
function(){
//no changes
}
)
.catch(
function(error) {
console.error('Error: ' + error);
}
);
我不知道为什么,但我在 hide/cancel
上收到 AngularJS MaterialmdDialog
的 unhandled rejection
错误
mdDialog
的代码:
$scope.addAttendee = function(ev) {
$mdDialog.show({
controller: DialogController,
templateUrl: 'views/regForm.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
controllerAs: 'ctrl',
fullscreen: $scope.customFullscreen, // Only for -xs, -sm breakpoints.
locals: {parent: $scope}
})
.then(function(response){
if(angular.isDefined(response)){
attendees.push(response);
}
console.log(attendees);
console.log(attendees.length);
})
当我删除承诺时,对话框可以关闭 w/o 错误消息。
知道这是怎么回事吗?
当 mdDiaglog
.
更新后的代码
$scope.addAttendee = function(ev) {
$mdDialog.show({
controller: DialogController,
templateUrl: 'views/regForm.tmpl.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose:true,
controllerAs: 'ctrl',
fullscreen: $scope.customFullscreen, // Only for -xs, -sm breakpoints.
locals: {parent: $scope}
})
.then(
function(response){
if(angular.isDefined(response)){
attendees.push(response);
console.log(attendees);
console.log(attendees.length);
}
},
function(){
//no changes
}
)
.catch(
function(error) {
console.error('Error: ' + error);
}
);