我对openBottomSheet
API遇到了一些困难。
这是我的HTML:
<md-button aria-label="Open Settings" ng-click="openBottomSheet($event)">
<ng-md-icon icon="more_vert"></ng-md-icon>
</md-button>
这将打开我的控制器中的openBottomSheet,如下所示:
$scope.openBottomSheet = function() {
$mdBottomSheet.show({
template: '<md-bottom-sheet>' +
'Hello! <md-button ng-click="closeBottomSheet()">Close</md-button>' +
'</md-bottom-sheet>'
})
// Fires when the hide() method is used
.then(function() {
console.log('You clicked the button to close the bottom sheet!');
})
// Fires when the cancel() method is used
.catch(function() {
console.log('You hit escape or clicked the backdrop to close.');
});
};
$scope.closeBottomSheet = function($scope, $mdBottomSheet) {
$mdBottomSheet.hide();
}
这是基于文档的,为什么我不能让它在我的项目中工作?
控制器注入:
.controller('containerCtrl', ['$scope', '$rootScope', '$stateParams', '$http', '_', '$q', '$state', '$mdBottomSheet','$mdSidenav', function ($scope, $rootScope, $stateParams, $http, $q, $state,$mdBottomSheet,$mdSidenav) {
这是我的错误:
main.min.js:3 TypeError:c.show不是函数
`c.show` is this line in controller: `$mdBottomSheet.show({` (minified version)
答案 0 :(得分:1)
删除控制器注入中的-
。字符串数组注入和服务注入都应该是相同且相同的顺序。
.controller('containerCtrl', ['$scope', '$rootScope', '$stateParams', '$http', '$q', '$state', '$mdBottomSheet','$mdSidenav',
function ($scope, $rootScope, $stateParams, $http, $q, $state,$mdBottomSheet,$mdSidenav) {