Angular Materialライブラリを使用していますが、$ mdDialogを動作させることができません。私は私がロード/サービスを正しく注入しているかどうかはわかりません。
var mainApp = angular.module("mainApp", ['ngRoute', 'ngMaterial'])
.config(['$routeProvider', function($routeProvider) {...omitted} ])
.service('selectedStudentService', function() {...omitted} ])
.service('appService', function($mdDialog){
this.showAlert = function(title, message, $mdDialog) {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title(title)
.textContent(message)
.ariaLabel()
.ok('OK!')
.targetEvent(messag
);
エラーが
Uncaught TypeError: Cannot read property 'show' of undefined
私が間違っているのかについての任意の考えである:ここでは
は、コードのですか?私は別のページでは、コントローラの下で同じ機能を使用する場合、それは次のコードmainApp.controller('aController', function ($mdDialog) {
$scope.showAlert = function(title, message) {
$mdDialog.show(
$mdDialog.alert()
.parent(angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true)
.title('Success')
.textContent(message)
.ariaLabel('b')
.ok('OK!')
.targetEvent(message)
);
};
}と同じように私のために[OK]を動作することを
注意。
$ mdDialog APIドキュメントのURLを助けてください:https://material.angularjs.org/latest/api/service/ $ mdDialog