我一直面临着角度材质Dialog的问题。这是我在控制器MenuCtrl中的代码
app.controller('MenuCtrl', ['$scope', '$mdSidenav', '$mdDialog', '$sce', '$state', 'base_url', 'RestaurantFactory', 'MenuManager', 'GetSelectedMenu', function($scope, $mdSidenav, $mdDialog, $sce, $state, base_url, RestaurantFactory, MenuManager, GetSele`enter code here`ctedMenu) {
$scope.getCustomizeMenu = function(event, menuItem) {
MenuManager.getSelectedMenu(menuItem.id).then(function(menuItems) {
console.log(menuItems);
$mdDialog.show({
locals: {
MenuItem: menuItem
},
templateUrl: 'templates/customize.html',
controller: 'CustomizeMenuCtrl',
parent: angular.element(document.body),
targetEvent: event,
clickOutsideToClose: true,
fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
}).then(function(answer) {
console.log(answer);
$scope.status = 'You said the information was "' + answer + '".';
}, function() {
$scope.status = 'You cancelled the dialog.';
});
}, function(err) {
console.log(err);
alert("Issue reported successfully.");
// $state.go('home');
});
};
}]);
这是我的CustomizeMenuCtrl
app.controller('CustomizeMenuCtrl', ['$scope', '$mdDialog', '$state', '$sce', 'base_url','MenuItem', function($scope, $mdDialog, $state,$sce, base_url, MenuItem) {
console.log(MenuItem);
$scope.hide = function() {
$mdDialog.hide();
};
$scope.cancel = function() {
$mdDialog.cancel();
};
$scope.answer = function(answer) {
$mdDialog.hide(answer);
};
}]);
我已经获得了我的本地值,但$ mdDialog无效,我收到了未知的提供程序错误。
这是我的模块宣言
var app= angular.module('RestoWebApp', ['ngMaterial', 'ngMdIcons', 'ui.router', 'uiRouterStyles']);
和index.html
<!DOCTYPE html>
<html lang="en" ng-app="RestoWebApp">
<head>
<meta charset="UTF-8">
<base href="/">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/angular-material/angular-material.min.css">
<!-- Angular Material Dependencies -->
<script src="lib/angular/angular.min.js"></script>
<script src="lib/angular/angular-animate.min.js"></script>
<script src="lib/angular/angular-aria.min.js"></script>
<script src="lib/angular-material/angular-material.min.js"></script>
<script src="lib/angular-material/angular-material-icons.min.js"></script>
<script src="lib/angular/angular-ui-router.min.js"></script>
<script src="lib/angular-ui-router-styles/ui-router-styles.js"></script>
<script src="js/app.js"></script>
<script src="js/Services/CommonServices.js"></script>
<script src="js/Services/CartServices.js"></script>
<script src="js/Services/MenuServices.js"></script>
<script src="js/Services/NotificationsServices.js"></script>
<script src="js/Services/OrderServices.js"></script>
<script src="js/Directives/CommonDirectives.js"></script>
<script src="js/Controllers/CartCtrl.js"></script>
<script src="js/Controllers/MenuCtrl.js"></script>
<script src="js/Controllers/NotificationsCtrl.js"></script>
<script src="js/Controllers/OrdersCtrl.js"></script>
<script src="js/Controllers/ProfileCtrl.js"></script>
<script src="js/Controllers/SidebarCtrl.js"></script>
<script src="js/Controllers/CustomizeMenuCtrl.js"></script> </head>
<body>
<div ng-controller="launchCtrl" layout="column" ui-router-styles>
<div ui-view flex> </div>
</div></body></html>
答案 0 :(得分:0)
可能你的MenuCtrl有待改变,
app.controller('MenuCtrl', ['$scope', '$mdSidenav', '$mdDialog', '$sce', '$state', 'base_url', 'RestaurantFactory', 'MenuManager', 'GetSelectedMenu', function($scope, $mdSidenav, $mdDialog, $sce, $state, base_url, RestaurantFactory, MenuManager, GetSelectedMenu) {