ionic popover


$ionicPopover

$ionicPopover es un marco de vista que puede flotar sobre el contenido de la app.

Puede implementar las siguientes funciones:

  • Mostrar más información en la página actual.
  • Seleccionar algunas herramientas o configuraciones.
  • Proporcionar una lista de operaciones en la página.

Métodos

fromTemplate(templateString, options)
o 
fromTemplateUrl(templateUrl, options)

Descripción de parámetros:

templateString: cadena de plantilla.

templateUrl: URL de la plantilla a cargar.

options: opciones de inicialización.

Ejemplo

Parte del código HTML

<p> <button ng-click="openPopover($event)">Abrir el popover</button> </p> <script id="my-popover.html" type="text/ng-template"> <ion-popover-view> <ion-header-bar> <h1 class="title">Mi título del popover</h1> </ion-header-bar> <ion-content> Hello! </ion-content> </ion-popover-view> </script>

Método fromTemplateUrl

angular.module('ionicApp', ['ionic']) .controller( 'AppCtrl',['$scope','$ionicPopover','$timeout',function($scope,$ionicPopover,$timeout){ $scope.popover = $ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }); //Método .fromTemplateUrl() $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(); }; //Eliminar el popover $scope.$on('$destroy', function() { $scope.popover.remove(); }); //Ejecutar después de ocultar el popover $scope.$on('popover.hidden', function() { //Ejecutar código }); //Ejecutar después de eliminar el popover $scope.$on('popover.removed', function() { //Ejecutar código }); }])

Pruébalo »

También podemos usar la plantilla como una cadena y utilizar el método .fromTemplate() para implementar el cuadro emergente:

Método fromTemplate

angular.module('ionicApp', ['ionic']) .controller( 'AppCtrl',['$scope','$ionicPopover','$timeout',function($scope,$ionicPopover,$timeout){ $scope.popover = $ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }); //Método .fromTemplate() var template = '<ion-popover-view><ion-header-bar> <h1 class="title">Mi título de cuadro flotante</h1> </ion-header-bar> <ion-content> Hello! </ion-content></ion-popover-view>'; $scope.popover = $ionicPopover.fromTemplate(template, { scope: $scope }); $scope.openPopover = function($event) { $scope.popover.show($event); }; $scope.closePopover = function() { $scope.popover.hide(); }; //Eliminar el popover $scope.$on('$destroy', function() { $scope.popover.remove(); }); //Ejecutar después de ocultar el popover $scope.$on('popover.hidden', function() { //Ejecutar código }); //Ejecutar después de eliminar el popover $scope.$on('popover.removed', function() { //Ejecutar código }); }])

Pruébalo »
Otras extensiones