mdDialog 无法读取未定义的 属性 'prompt'

mdDialog cannot read property 'prompt' of undefined

我是 angularjs 的新手,所以 material,我在尝试使用 mdDialog 时遇到问题,找不到答案。调用函数时它一直返回 mdDialog is undefined.

按照最后尝试的代码:

var corenotes = angular.module('corenotes',["ngAnimate", "ngAria", "ngMessages", 'ngMaterial', "ngMdIcons"] );

corenotes.controller('BoardController',['$scope', '$mdDialog', function($scope, $mdDialog, $http) {

[...]

  $scope.showModal = function(ev, $mdDialog){
      // Appending dialog to document.body to cover sidenav in docs app
      var confirm = $mdDialog.prompt()
            .title('What would you name your dog?')
            .textContent('Bowser is a common name.')
            .placeholder('dog name')
            .ariaLabel('Dog name')
            .targetEvent(ev)
            .ok('Okay!')
            .cancel('I\'m a cat person');
      $mdDialog.show(confirm).then(function(result) {
        $scope.status = 'You decided to name your dog ' + result + '.';
      }, function() {
        $scope.status = 'You didn\'t name your dog.';
      });
  };


}]);

中删除 $mdDialog
$scope.showModal = function(ev, $mdDialog) {

像这样

function showDialog($event) {

这是 $mdDialog 的文档:

https://material.angularjs.org/latest/api/service/$mdDialog