mardi 17 février 2015

$mdToast, $mdDialog is not working in route


I was happily calling $mdDialog.show or $mdToast.showbut I started to use $routeProvider, I can't use them anymore, I'm getting this error when I tried to open toast or dialog:



TypeError: Cannot read property 'overflow' of undefined
at forEach.css (http://ift.tt/19pTxaC)
at Object.JQLite.(anonymous function) [as css] (http://ift.tt/1yOFrEP)
at Object.s [as onShow] (http://ift.tt/19pTxHG)
at http://ift.tt/1yOFuAd
at processQueue (http://ift.tt/19pTxHI)
at http://ift.tt/1yOFuAh
at Scope.$eval (http://ift.tt/19pTxaG)
at Scope.$digest (http://ift.tt/1yOFxfE)
at Scope.$apply (http://ift.tt/19pTxHM)
at done (http://ift.tt/1yOFuAl)


Here is my app:



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 only has a lot of divs.


index.tmp.html (when the page is first rendered):



<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/assets/css/stil.css"/>
<link rel="stylesheet" href="http://ift.tt/19pTxHO">
<link rel="stylesheet" href="http://ift.tt/1yOFuAq">
<script src="http://ift.tt/X4dRIX"></script>
<script src="http://ift.tt/169jEAW"></script>
<script src="http://ift.tt/19pTxHQ"></script>
<script src="http://ift.tt/1yOFuAs"></script>
<script src="http://ift.tt/1yCqqGb"></script>
<script src="http://ift.tt/1yOFxw2"></script>
<script type="text/javascript" src="/assets/js/app.js"></script>
</head>
<body ng-app="APP" ng-view></body>
</html>


What can be the problem? I want to use Dialog and Toast classes. I'm new to angularjs.





Aucun commentaire:

Enregistrer un commentaire