ionic フローティングボックス


$ionicPopover

$ionicPopover は、アプリのコンテンツ上に浮かせることのできるビューボックスです。

以下の機能を実現できます:

  • 現在のページでより多くの情報を表示する。
  • ツールや設定を選択する。
  • ページに操作リストを提供する。

メソッド

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

パラメータ説明:

templateString: テンプレート文字列。

templateUrl: ロードするテンプレート URL。

options: 初期化オプション。

例

HTML コード部分

<p> <button ng-click="openPopover($event)">フローティングボックスを開く</button> </p> <script id="my-popover.html" type="text/ng-template"> <ion-popover-view> <ion-header-bar> <h1 class="title">私のフローティングボックスタイトル</h1> </ion-header-bar> <ion-content> Hello! </ion-content> </ion-popover-view> </script>

fromTemplateUrl メソッド

angular.module('ionicApp', ['ionic']) .controller( 'AppCtrl',['$scope','$ionicPopover','$timeout',function($scope,$ionicPopover,$timeout){ $scope.popover = $ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }); //.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(); }; //フローティングボックスを削除 $scope.$on('$destroy', function() { $scope.popover.remove(); }); //フローティングボックスを非表示にした後に実行 $scope.$on('popover.hidden', function() { //コードを実行 }); //フローティングボックスを削除した後に実行 $scope.$on('popover.removed', function() { //コードを実行 }); }])

試してみる »

また、テンプレートを文字列として扱い、.fromTemplate() メソッドを使用してポップアップを実装することもできます:

fromTemplate メソッド

angular.module('ionicApp', ['ionic']) .controller( 'AppCtrl',['$scope','$ionicPopover','$timeout',function($scope,$ionicPopover,$timeout){ $scope.popover = $ionicPopover.fromTemplateUrl('my-popover.html', { scope: $scope }); //.fromTemplate() メソッド var template = '<ion-popover-view><ion-header-bar> <h1 class="title">私のフローティングボックスタイトル</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(); }; //フローティングボックスを削除 $scope.$on('$destroy', function() { $scope.popover.remove(); }); //フローティングボックスを非表示にした後に実行 $scope.$on('popover.hidden', function() { //コードを実行 }); //フローティングボックスを削除した後に実行 $scope.$on('popover.removed', function() { //コードを実行 }); }])

試してみる »
その他の拡張機能