我尝试为对话框定义一个控制器,如Angular Material示例中所示(here)
app/models/concerns/rent_readiness.rb
但我总是这样:
错误:[$ injector:unpr]未知提供程序:DialogControllerProvider< - DialogController< - MainController
答案 0 :(得分:0)
您无法注入控制器。因此,从DialogController
中的依赖项注入参数中删除MainController
,并使用controller: 'DialogController'
进行对话:
TestApp.controller('MainController', function MainController($scope, $mdDialog, $mdMedia) {
// ...
$scope.showImprintDialog = function(ev) {
var useFullScreen = ($mdMedia('sm') || $mdMedia('xs')) && $scope.customFullscreen;
$mdDialog.show({
controller: 'DialogController',
templateUrl: 'impressum.html',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: useFullScreen
})
.then(function(answer) {
$scope.status = 'You said the information was "' + answer + '".';
}, function() {
$scope.status = 'You cancelled the dialog.';
});
$scope.$watch(function() {
return $mdMedia('xs') || $mdMedia('sm');
}, function(wantsFullScreen) {
$scope.customFullscreen = (wantsFullScreen === true);
});
};
// ...
});