Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何摆脱mdDialog控制台错误无法读取null的属性元素?_Javascript_Angularjs - Fatal编程技术网

Javascript 如何摆脱mdDialog控制台错误无法读取null的属性元素?

Javascript 如何摆脱mdDialog控制台错误无法读取null的属性元素?,javascript,angularjs,Javascript,Angularjs,我有Left\u template\u view\u html和center\u template\u view\u html 点击Left\u template\u view\u html中的md按钮 我正试图打开document.body上的mdDialog 我必须在parent中提供的内容:angular.element()? 在下面的代码中避免控制台错误。功能对我来说很好 $scope.showAdvancedSelection = function(ev,templateURL) {

我有
Left\u template\u view\u html
center\u template\u view\u html

点击
Left\u template\u view\u html中的
md按钮

我正试图打开
document.body上的
mdDialog

我必须在parent中提供的内容:
angular.element()

在下面的代码中避免控制台错误。功能对我来说很好

 $scope.showAdvancedSelection = function(ev,templateURL) {

$mdDialog.show({
            controller: DialogController,
            template: templateURL,
            parent: angular.element(document.getElementById(document.body)),
            targetEvent: ev,
            clickOutsideToClose: true
        })
        .then(function (answer) {
            $scope.status = 'true';
        }, function () {
            $scope.status = 'You cancelled the dialog.';
        });
   };
错误

angular.js:14525 TypeError:无法读取null的属性“element”
在f(角度材料最小值:16)
在有角度的材料上。最小js:16
在angular.js:16832
m.$digest(angular.js:17971)
在m.$apply(angular.js:18269)
在l(angular.js:12387)
在XMLHttpRequest.A.onload(angular.js:12541)“可能未处理的拒绝:{}”

使用-

父级:angular.element(document.body)

app.config(['$qProvider',function($qProvider){$qProvider.errorOnUnhandledRejections(false);}]);------>这个代码解决了我的问题