我对角质材料还不熟悉,我正在努力使$ material服务发挥作用。我用的是角质材料的演示,但不知怎么的,我似乎搞错了。我需要补充什么才能让它起作用/我做错了什么。
Demo https://material.angularjs.org/latest/api/service/$mdDialog
我的html
<div ng-controller="myController">
<md-button ng-click="showAlert()" class="md-raised md-warn">Custom Dialog</md-button>
</div>我的JS
app.controller('myController', ['$scope', '$mdToast', '$animate', '$mdDialog', '$mdMedia', function ($scope, $mdToast, $mdDialog,$animate, $mdMedia ) {
var alert;
$scope.showAlert = showAlert;
// Internal method
function showAlert() {
alert = $mdDialog.alert({
title: 'Attention',
textContent: 'This is an example of how easy dialogs can be!',
ok: 'Close'
});
$mdDialog
.show( alert )
.finally(function() {
alert = undefined;
});
}
}发布于 2016-03-23 15:25:11
这是一个很常见的问题,但是注入数组中模块的顺序必须与函数参数中模块的顺序匹配。
改变这一点:
app.controller('myController',
['$scope', '$mdToast', '$animate', '$mdDialog', '$mdMedia',
function ($scope, $mdToast, $mdDialog, $animate, $mdMedia )对此:
app.controller('myController',
['$scope', '$mdToast', '$animate', '$mdDialog', '$mdMedia',
function ($scope, $mdToast, $animate, $mdDialog, $mdMedia )发布于 2017-01-07 07:30:25
实际上,您不应该手动指定注入名称。使用ng-注释,在Grunt和Gulp中都有。
https://github.com/olov/ng-annotate
https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#style-y101
https://stackoverflow.com/questions/36181859
复制相似问题