Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript $mdToast,$mdDialog在路由中不工作_Javascript_Angularjs_Angularjs Routing_Material Design - Fatal编程技术网

Javascript $mdToast,$mdDialog在路由中不工作

Javascript $mdToast,$mdDialog在路由中不工作,javascript,angularjs,angularjs-routing,material-design,Javascript,Angularjs,Angularjs Routing,Material Design,我很高兴地打电话给$mdDialog.show或$mdToast.show,但我开始使用$routeProvider,我不能再使用它们了,我在尝试打开toast或dialog时遇到了以下错误: 这是我的应用程序: var app = angular.module('APP', ['ngMaterial', 'ngRoute']) app.config(['$routeProvider', function($routeProvider) { $routeProvider.

我很高兴地打电话给$mdDialog.show或$mdToast.show,但我开始使用$routeProvider,我不能再使用它们了,我在尝试打开toast或dialog时遇到了以下错误:

这是我的应用程序:

var app = angular.module('APP', ['ngMaterial', 'ngRoute'])

app.config(['$routeProvider',
function($routeProvider) {
    $routeProvider.
        when('/', {
            templateUrl: '/assets/tpl/ana.tmp.html',
            controller: 'cbiKontrol'
        })
}]);
app.controller('cbiKontrol', ['$scope', '$mdDialog', '$window', '$mdToast', '$location' , function($scope, $mdDialog, $window, $mdToast, $location){

   var toastShow = function(content) {
       $mdToast.show({
         template: '<md-toast><span flex>'+content+'</span></md-toast>',
         hideDelay: 1800,
         position: "top right"
       })
   }
   //toastShow("test") 
})

有什么问题吗?我想使用Dialog和Toast类。我是angularjs的新手。

您还没有显示任何代码,其中包含您正在询问的angularjs材质指令。@Claies谢谢提醒。我使用的是:对,这些是指令,但您没有在这里显示在代码中调用它们的位置。您的代码看起来正确,我看不到任何可能导致此冲突的内容。您可能需要为材质设计团队提交错误报告@埃索蒂,里面有溶液。
var app = angular.module('APP', ['ngMaterial', 'ngRoute'])

app.config(['$routeProvider',
function($routeProvider) {
    $routeProvider.
        when('/', {
            templateUrl: '/assets/tpl/ana.tmp.html',
            controller: 'cbiKontrol'
        })
}]);
app.controller('cbiKontrol', ['$scope', '$mdDialog', '$window', '$mdToast', '$location' , function($scope, $mdDialog, $window, $mdToast, $location){

   var toastShow = function(content) {
       $mdToast.show({
         template: '<md-toast><span flex>'+content+'</span></md-toast>',
         hideDelay: 1800,
         position: "top right"
       })
   }
   //toastShow("test") 
})
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/assets/css/stil.css"/>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.7.0/angular-material.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=RobotoDraft:400,500,700,400italic">
<script src="http://hammerjs.github.io/dist/hammer.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/0.7.0/angular-material.min.js"></script>
<script type="text/javascript" src="/assets/js/app.js"></script>
</head>
<body ng-app="APP" ng-view></body>
</html>