我有一个导航按钮,应该显示一个弹出框
<ion-nav-buttons side="secondary">
<button class="button button-icon icon ion-more" ng-click="openPopover($event)"></button>
</ion-nav-buttons>
这是控制器
.controller('MyController', ['$scope','$ionicPopover', function($scope, $ionicPopover) {
$ionicPopover.fromTemplateUrl('popover.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
$scope.closePopover = function() {
$scope.popover.hide();
};
$scope.$on('$destroy', function () {
$scope.popover.remove();
});
}])
但是当我点击导航按钮时,我面对TypeError: Cannot read property 'show' of undefined at Scope.$scope.openPopover
这是我在同一个项目文件夹中的模板
<ion-popover-view>
<ion-content>
<div class="list">
<label class="item item-input" ng-click="addFavorite(dish.id)">
<div class="input-label">
Add To Favorites
</div>
</label>
<label class="item item-input" ng-click="openModal()">
<div class="input-label">
Add A Comment
</div>
</label>
</div>
</ion-content>
</ion-popover-view>