Reputation: 713
I want to show toast in my app. For that I used:
mySchoolApp.controller('loginController', ['$scope', '$http', function($scope, $http,$location, $mdToast) {
this.loginForm = function() {
let uname = this.inputData.username;
let pass= this.inputData.password;
if (pass === 123456) {
sessionStorage.setItem("userID", '123456');
window.location.href = '#dashboard';
} else {
$mdToast.show(
$mdToast.simple()
.textContent('Either email or password is incorrect!')
.position("top right")
.hideDelay(3000)
);
}
})
.error(function(data, status, headers, config) {
//error msgs
})
}
}]);
But while running my app,its showing the following error:
TypeError: Cannot read property 'show' of undefined
How to sort this issue in my app?
Upvotes: 0
Views: 723
Reputation: 1291
You're missing the toast service from your controller's dependency injection array:
mySchoolApp.controller('loginController', ['$scope', '$http', '$location', '$mdToast', function($scope, $http,$location, $mdToast) ......
Upvotes: 1