$mdDialog 传递本地未知提供者
$mdDialog pass locals unknown provider
我见过很多像我这样的问题,但答案似乎并没有解决我的问题。奇怪的是它以前是有效的。此外,当我在用于对话框的控制器中放置断点时,用于传递值的变量不为空。该值已正确传递但仍然是未知提供程序错误
这是我父控制器中的代码
function addFaq(category, ev){
$mdDialog.show({
controller: 'newfaqController'
, templateUrl: './app/components/faq/modals/newFaq.html'
, parent: angular.element(document.body)
, targetEvent: ev
, bindToController: true
, clickOutsideToClose: true
, locals: {
newFaqCategory: category
}
, controllerAs: vm
}).then(function(result){
if(result){
vm.allFaqs.push(result);
}
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
这些是我的对话框控制器的第一行
angular.module('MyApp').controller('newfaqController', ['$mdDialog', 'newFaqCategory', 'apiFactory', newfaqController]);
function newfaqController($mdDialog, newFaqCategory, apiFactory) {
Are you referencing the controller that calls $mdDialog as vm as well? I've run into conflicts with this and us dvm (dialog view model) as the controller reference in $mdDialog.
这就是答案,我也可以将 "ControllerAs" 远离选项。但仍然必须在我的模态控制器中将 vm 更改为 dvm
function addFaq(category, ev){
$mdDialog.show({
controller: 'newfaqController'
, templateUrl: './app/components/faq/modals/newFaq.html'
, parent: angular.element(document.body)
, targetEvent: ev
, bindToController: true
, clickOutsideToClose: true
, locals: {
newFaqCategory: category
}
}).then(function(result){
if(result){
vm.allFaqs.push(result);
}
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
还有我的模态控制器
angular.module('MyApp').controller('newfaqController', ['$mdDialog', 'newFaqCategory', 'apiFactory', newfaqController]);
function newfaqController($mdDialog, newFaqCategory, apiFactory) {
var dvm = 这个;
我见过很多像我这样的问题,但答案似乎并没有解决我的问题。奇怪的是它以前是有效的。此外,当我在用于对话框的控制器中放置断点时,用于传递值的变量不为空。该值已正确传递但仍然是未知提供程序错误
这是我父控制器中的代码
function addFaq(category, ev){
$mdDialog.show({
controller: 'newfaqController'
, templateUrl: './app/components/faq/modals/newFaq.html'
, parent: angular.element(document.body)
, targetEvent: ev
, bindToController: true
, clickOutsideToClose: true
, locals: {
newFaqCategory: category
}
, controllerAs: vm
}).then(function(result){
if(result){
vm.allFaqs.push(result);
}
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
这些是我的对话框控制器的第一行
angular.module('MyApp').controller('newfaqController', ['$mdDialog', 'newFaqCategory', 'apiFactory', newfaqController]);
function newfaqController($mdDialog, newFaqCategory, apiFactory) {
Are you referencing the controller that calls $mdDialog as vm as well? I've run into conflicts with this and us dvm (dialog view model) as the controller reference in $mdDialog.
这就是答案,我也可以将 "ControllerAs" 远离选项。但仍然必须在我的模态控制器中将 vm 更改为 dvm
function addFaq(category, ev){
$mdDialog.show({
controller: 'newfaqController'
, templateUrl: './app/components/faq/modals/newFaq.html'
, parent: angular.element(document.body)
, targetEvent: ev
, bindToController: true
, clickOutsideToClose: true
, locals: {
newFaqCategory: category
}
}).then(function(result){
if(result){
vm.allFaqs.push(result);
}
});
$scope.$watch(function () {
return $mdMedia('xs') || $mdMedia('sm');
}, function (wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
还有我的模态控制器
angular.module('MyApp').controller('newfaqController', ['$mdDialog', 'newFaqCategory', 'apiFactory', newfaqController]);
function newfaqController($mdDialog, newFaqCategory, apiFactory) { var dvm = 这个;