I can't seem to figure out what's causing this issue...
Following the Angular material design guidelines, I expected this code to work. However, I keep getting an error that says:
TypeError: Cannot read property 'show' of undefined
Here is a snippet of my code:
<!DOCTYPE html>
<html lang="en" ng-app="Main">
<!-- some stuff here -->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc4/angular-material.min.css">
</head>
<body ng-controller="MainCtrl as ctrl">
<div ng-click="executeToast()">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-sanitize.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0-rc4/angular-material.min.js"></script>
</body>
</html>
And here is the controller code:
angular.module('MainController', [
'MainService',
'MainDirective',
'ngMaterial',
'ngMessages',
'ngSanitize'
])
.controller('MainCtrl', [ '$scope', '$sce', '$mdToast', function($scope, Main, $sce, $apply, $rootScope, $mdToast) {
$scope.executeToast() = function() {
$mdToast.show($mdToast.simple({
hideDelay: 3000,
position: 'top left',
content: 'testing',
toastClass: 'success'
}));
}
}]);
If you have any insights or solutions, please let me know! Thanks!