Reputation: 25
$mdToast.simple is not a function
$scope.showToast = function() {
var pinTo = $scope.getToastPosition();
$mdToast.show(
$mdToast.simple()
.textContent('Saved!')
.position(pinTo )
.hideDelay(2000)
);
};
Put as much of my code in here as I could, still same issue.. is it the order of things or a version? I have rearranged and tried many things but still getting the same error. Checked this site and git issues for similar fixes but looks like OP never comes back with what works.
It also seems like it is trying to get the function from angular.js rather than angular-material.js?
Thanks all
The Fix
My Code:
var app = angular.module('app', ['firebase', 'ngMaterial', 'ngRoute']);
app.controller('MainCtrl', ['$scope', '$rootScope',
function($scope, $mdToast, $firebaseObject, $rootScope) {
Working code:
var app = angular.module('app', ['firebase', 'ngMaterial', 'ngRoute']);
app.controller('MainCtrl', ['$scope', '$mdToast', '$rootScope',
function($scope, $mdToast, $firebaseObject, $rootScope) {
Upvotes: 0
Views: 1335
Reputation: 222582
Problem was you are missing the `'$mdToast', '$firebaseObject', in the dependency injection
app.controller('MainCtrl', ['$scope', '$mdToast', '$firebaseObject', '$rootScope',
function($scope, $mdToast, $firebaseObject, $rootScope) {
Upvotes: 1