所以我用Yeoman创建了一个项目(角度全栈,角度材料),当我单击div时,应该显示md-dialog框。现在发生的是,我的页面被加载了两次,尽管您看到了叠加层(http://gyazo.com/c5e05ca2045c3ed9c32bb38d7bf67fc9),但没有弹出窗口可见。我猜想它把我的dialog1.tmpl.html看作是一个全新的视图。那么,如何解决此问题?

我的部分代码用于触发弹出窗口:

$scope.showPopUp = function(ev) {
            $mdDialog.show({
                controller: DialogController,
                templateUrl: 'dialog1.tmpl.html',
                parent: angular.element(document.body),
                targetEvent: ev,
            })

            function DialogController($scope, $mdDialog) {

                if (editId) {
                    $http.get('/api/task/' + editId).success(function(data) {

                            console.log("data variabele uit de dialogController", data);

                            $scope.task_name = data.name;
                            $scope.task_project_id = data.project_id;
                            globalTask_Project = data.project_id;
                            $scope.task_location = data.location_id;
                            globalTask_location = data.location_id;
                            $scope.task_estimate_time = data.estimate_time;
                            $scope.task_project_client_name = data.project_client_name;
                            $scope.task_url = data.url;
                            $scope.task_resource_link = data.resource_link;
                            $scope.task_notes = data.task_notes;

                            $scope.closeDialog = function() {
                                var mainApp = angular.element(document.body).controller();
                                $mdDialog.hide();
                                editId = null;
                                globalTask_location = null;
                                globalTask_Project = null;
                            }

                        })
                        .error(function(data, status, headers, config) {
                            console.log("Error in retrieving data from server");
                        });
                } else {
                    $scope.closeDialog = function() {
                        var mainApp = angular.element(document.body).controller();
                        $mdDialog.hide();
                    }
                }

            }
        }

最佳答案

解决此问题的方法是我必须正确设置templateUrl的路由,因此必须使用templateUrl而不是templateUrl:'dialog1.tmpl.html':'app / calendar / month / dialog1.tmpl.html'

10-04 17:33