未知提供者:显示 material angular 对话框时,eProvider <- e
Unknown provider: eProvider <- e when showing material angular dialog
我正在尝试连接 material angular 的对话。下面的代码。我收到错误,Unknown provider: eProvider <- e
。
Js
var app = angular.module('app', ['ngMaterial']);
var dialogController = app.controller('dialogController', ['$scope', '$mdDialog', function($scope, $mdDialog) {
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}]);
app.controller('mainController', ['$scope', '$http', '$mdDialog', function ($scope, $http, $mdDialog) {
$scope.showDialog = function (e) {
e.preventDefault();
$mdDialog.show({
controller: dialogController,
templateUrl: 'sign-in.html',
targetEvent: e
});
};
}]);
Html
<a href="#" ng-click="showDialog($event)">Show dialog</a>
<script type="text/ng-template" id="sign-in.html">
hello there
</script>
我错过了什么吗?
尝试在控制器名称中添加单引号:
$mdDialog.show({
controller: 'dialogController',
templateUrl: 'sign-in.html',
targetEvent: e
});
编辑:
我有一件事要更新,我知道为什么会发生错误“'getBoundingClientRect' of undefined”。您必须使用此脚本作为模板:
<script type="text/ng-template" id="sign-in.html">
<md-dialog>
<md-content>Hello there</md-content>
</md-dialog>
</script>
顺便说一句,我关于单引号的回答应该在第一时间起作用。使用这个新模板再试一次。
var app = angular.module('app', ['ngMaterial']);
var dialogController = function($scope, $mdDialog) {
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
};
app.controller('mainController', ['$scope', '$http', '$mdDialog', function ($scope, $http, $mdDialog) {
$scope.showDialog = function (e) {
$mdDialog.show({
controller: dialogController,
templateUrl: 'sign-in.html',
targetEvent: e
});
};
}]);
HTML 可以这样称呼它:
<md-button class="md-primary" ng-click="showDialog($event)">Show dialog</md-button>
我正在尝试连接 material angular 的对话。下面的代码。我收到错误,Unknown provider: eProvider <- e
。
Js
var app = angular.module('app', ['ngMaterial']);
var dialogController = app.controller('dialogController', ['$scope', '$mdDialog', function($scope, $mdDialog) {
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}]);
app.controller('mainController', ['$scope', '$http', '$mdDialog', function ($scope, $http, $mdDialog) {
$scope.showDialog = function (e) {
e.preventDefault();
$mdDialog.show({
controller: dialogController,
templateUrl: 'sign-in.html',
targetEvent: e
});
};
}]);
Html
<a href="#" ng-click="showDialog($event)">Show dialog</a>
<script type="text/ng-template" id="sign-in.html">
hello there
</script>
我错过了什么吗?
尝试在控制器名称中添加单引号:
$mdDialog.show({
controller: 'dialogController',
templateUrl: 'sign-in.html',
targetEvent: e
});
编辑: 我有一件事要更新,我知道为什么会发生错误“'getBoundingClientRect' of undefined”。您必须使用此脚本作为模板:
<script type="text/ng-template" id="sign-in.html">
<md-dialog>
<md-content>Hello there</md-content>
</md-dialog>
</script>
顺便说一句,我关于单引号的回答应该在第一时间起作用。使用这个新模板再试一次。
var app = angular.module('app', ['ngMaterial']);
var dialogController = function($scope, $mdDialog) {
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
};
app.controller('mainController', ['$scope', '$http', '$mdDialog', function ($scope, $http, $mdDialog) {
$scope.showDialog = function (e) {
$mdDialog.show({
controller: dialogController,
templateUrl: 'sign-in.html',
targetEvent: e
});
};
}]);
HTML 可以这样称呼它:
<md-button class="md-primary" ng-click="showDialog($event)">Show dialog</md-button>