我很高兴地打电话给$mdDialog.show
或$mdToast.show
,但我开始使用$routeProvider
,我不能再使用它们了,当我尝试使用时,我收到此错误开放式吐司或对话:
TypeError: Cannot read property 'overflow' of undefined
at forEach.css (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:2831:27)
at Object.JQLite.(anonymous function) [as css] (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:2944:27)
at Object.s [as onShow] (https://ajax.googleapis.com/ajax/libs/angular_material/0.7.0/angular-material.min.js:121:1344)
at https://ajax.googleapis.com/ajax/libs/angular_material/0.7.0/angular-material.min.js:55:2782
at processQueue (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:13137:27)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:13153:27
at Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:14353:28)
at Scope.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:14169:31)
at Scope.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:14457:24)
at done (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.6/angular.js:9614:47)
这是我的应用:
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")
})
ana.tmp.html
只有很多div。
index.tmp.html(首次呈现页面时):
<!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>
可能是什么问题?我想使用Dialog和Toast类。我是angularjs的新手。