AngularJS材料mdDialog和未经处理的拒绝承诺

AngularJS材料mdDialog和未经处理的拒绝承诺,angularjs,angularjs-material,Angularjs,Angularjs Material,我不知道为什么,但我在隐藏/取消时收到了AngularJS材料的未处理拒绝错误mdDialog mdDialog的代码: $scope.addAttendee = function(ev) { $mdDialog.show({ controller: DialogController, templateUrl: 'views/regForm.tmpl.html', parent: angular.element(document.body), target

我不知道为什么,但我在隐藏/取消时收到了AngularJS材料的
未处理拒绝
错误
mdDialog

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);
})
当我删除承诺时,对话框可以关闭,而不显示错误消息


有什么线索吗?

mdiaglog
中的承诺没有更改(隐藏/取消)时,我需要一个函数

更新后的代码

$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);
    }
);  

“未经处理的拒绝”表示承诺被拒绝,但错误未得到处理。添加
.catch
,找出错误所在,并在每次有可能拒绝承诺时执行此操作。尝试添加如下拒绝函数:
。然后(函数(响应){},函数(拒绝){//console.log(拒绝)})
来消除错误。我看到mdDialog仍然让您感到头疼,哈哈。问候。dude@JackTheKnifeIt返回被拒绝的承诺是正常的。如果收到未处理的拒绝,则可能是
中的代码。然后
块抛出错误。变量
Attendes
可能不是数组,因此
UncaughtTypeError:无法读取属性“push”
。在
之后添加一个
.catch
块。然后
块查看错误。或者任何人:如何加载/显示一个md对话框以在catch调用中显示错误?