我正在尝试通过单击带有 Angular 的按钮来打开模式。在 btn click 调用的函数上,我有下面提到的代码:
function openAddVideoModal() {
var modalInstance = $mdDialog.show({
templateUrl: 'createDesign.html',
controller: 'createDesignCtrl',
resolve: {
currentUser: function () {
return _this.currentUser;
},
postOptions: function() {
return {"receiverId":0};
}
},
parent: angular.element(document.body),
clickOutsideToClose:true,
fullscreen: false
});
}
但是,当我点击按钮时,我收到了这个错误信息:
TypeError: $mdDialog.show is not a function
有人可以帮忙吗?提前谢谢你。
最佳答案
你在你的 Controller 工厂函数中以错误的顺序注入(inject)了依赖
改变
.controller('Ctrl', [
'$rootScope', '$scope', '$state', '$mdDialog', '$window', 'CONFIG_CONSTANTS', 'LanguageService',
function($rootScope, $scope, $window, $state, $mdDialog, CONFIG_CONSTANTS, LanguageService) {
To(将 $window
从第 3 位移动到第 5 位)
.controller('Ctrl', [
'$rootScope', '$scope', '$state', '$mdDialog', '$window', 'CONFIG_CONSTANTS', 'LanguageService',
function($rootScope, $scope, $state, $mdDialog, $window, CONFIG_CONSTANTS, LanguageService) {
始终确保依赖项必须以相似的顺序使用,就像您将它们注入(inject)到依赖项的 inline array
中一样。
关于javascript - Angular 错误 $mdDialog.show 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48425011/