Md-dialog弹出框(angular-material)作为新视图加载(Yeoman)

时间:2015-07-20 09:24:54

标签: javascript jquery angularjs angular-material

所以我用Yeoman创建了一个项目(angular-fullstack,angular-material),当我点击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();
                    }
                }

            }
        }

1 个答案:

答案 0 :(得分:1)

这个问题的解决方案是我必须将templateUrl的路线设置为正确而不是templateUrl:' dialog1.tmpl.html'它必须是templateUrl:' app / calendar / month / dialog1.tmpl.html'