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, 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>
4

1 回答 1

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) {
于 2017-02-03T09:11:21.987 回答