$ionicPopover
Related: ionicPopover controller.
The Popover is a view that floats above an app’s content. Popovers provide an easy way to present or gather information from the user and are commonly used in the following situations:
- Show more info about the current view
- Select a commonly used tool or configuration
- Present a list of actions to perform inside one of your views
Put the content of the popover inside of an <ion-popover-view>
element.
Usage
<p>
<button ng-click="openPopover($event)">Open Popover</button>
</p>
<script id="my-popover.html" type="text/ng-template">
<ion-popover-view>
<ion-header-bar>
<h1 class="title">My Popover Title</h1>
</ion-header-bar>
<ion-content>
Hello!
</ion-content>
</ion-popover-view>
</script>
angular.module('testApp', ['ionic'])
.controller('MyController', function($scope, $ionicPopover) {
// .fromTemplate() method
var template = '<ion-popover-view><ion-header-bar> <h1 class="title">My Popover Title</h1> </ion-header-bar> <ion-content> Hello! </ion-content></ion-popover-view>';
$scope.popover = $ionicPopover.fromTemplate(template, {
scope: $scope
});
// .fromTemplateUrl() method
$ionicPopover.fromTemplateUrl('my-popover.html', {
scope: $scope
}).then(function(popover) {
$scope.popover = popover;
});
$scope.openPopover = function($event) {
$scope.popover.show($event);
};
$scope.closePopover = function() {
$scope.popover.hide();
};
//Cleanup the popover when we're done with it!
$scope.$on('$destroy', function() {
$scope.popover.remove();
});
// Execute action on hidden popover
$scope.$on('popover.hidden', function() {
// Execute action
});
// Execute action on remove popover
$scope.$on('popover.removed', function() {
// Execute action
});
});
Methods
fromTemplate(templateString, options)
Param | Type | Details |
---|---|---|
templateString |
string
|
The template string to use as the popovers's content. |
options |
object
|
Options to be passed to the initialize method. |
- Returns:
object
An instance of anionicPopover
controller (ionicPopover is built on top of $ionicPopover).
fromTemplateUrl(templateUrl, options)
Param | Type | Details |
---|---|---|
templateUrl |
string
|
The url to load the template from. |
options |
object
|
Options to be passed to the initialize method. |
- Returns:
promise
A promise that will be resolved with an instance of anionicPopover
controller (ionicPopover is built on top of $ionicPopover).