I have a nav button that should show a popover
<ion-nav-buttons side="secondary">
<button class="button button-icon icon ion-more" ng-click="openPopover($event)"></button>
</ion-nav-buttons>
and this is the controller
.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();
});
}])
but when I click on the nav button I face the TypeError: Cannot read property 'show' of undefined at Scope.$scope.openPopover
here is the template which I have in the same project folder
<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>