asp.net - 弹出对话框错误:无法读取未定义的属性“显示”
问题描述
我在使用 angularJS 显示弹出对话框时遇到问题。我正在尝试使用演示站点进行锻炼。 https://material.angularjs.org/latest/demo/dialog。以下代码是我的控制器 js 代码。
(function () {
'use strict';
angular
.module('FramesPopup', ['ngRoute', 'ngMaterial' ])
.controller('PopupController', PopupController);
PopupController.$inject = ['$scope'];
function PopupController($scope, $mdDialog) {
$scope.title = 'PopupController';
$scope.status = ' ';
$scope.customFullscreen = false;
$scope.showAlert = function (ev) {
// Appending dialog to document.body to cover sidenav in docs app
// Modal dialogs should fully cover application
// to prevent interaction outside of dialog
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('This is an alert title')
.textContent('You can specify some description text in here.')
.ariaLabel('Alert Dialog Demo')
.ok('Got it!')
.targetEvent(ev)
);
};
activate();
function activate() {
console.log("test");
}
}
})();
解决方案
注释列表$mdDialog
中缺少该服务:$inject
angular
.module('FramesPopup', ['ngRoute', 'ngMaterial' ])
.controller('PopupController', PopupController);
̶P̶o̶p̶u̶p̶C̶o̶n̶t̶r̶o̶l̶l̶e̶r̶.̶$̶i̶n̶j̶e̶c̶t̶ ̶=̶ ̶[̶'̶$̶s̶c̶o̶p̶e̶'̶]̶;̶
PopupController.$inject = ['$scope','$mdDialog'];
function PopupController($scope, $mdDialog) {
$scope.title = 'PopupController';
$scope.status = ' ';
$scope.customFullscreen = false;
$scope.showAlert = function (ev) {
// Appending dialog to document.body to cover sidenav in docs app
// Modal dialogs should fully cover application
// to prevent interaction outside of dialog
$mdDialog.show(
$mdDialog.alert()
推荐阅读
- apache - Apache mod_jk 负载均衡问题
- oracle - 甲骨文 11g CQN。一个记录更新的两个不同的 ROWID
- visual-studio - 我无法找到我的应用程序的位置下拉菜单(自动完成)。下面给出代码
- c# - 需要一些关于结合两个类的帮助
- c# - Selenium C# 在输入之前将光标设置为输入的结尾
- r - 如何在 R 中具有多个标题行的 flextable 中设置标题标签?
- encoding - 在 DataWeave mule 4 中编码重音字母
- git - SourceTree - 在 Unstaged 文件部分标记为“丢失”的文件 - 无法摆脱它们
- php - 为什么我的数据库仍然显示 2147483647 错误?
- javascript - 从查询到mysql数据库的cookie中的条目问题