×
ionic 教程ionic 安装ionic 创建 APP

ionic CSS

ionic 头部与底部ionic 按钮ionic 列表ionic 卡片ionic 表单和输入框ionic toggleionic checkboxionic 单选框ionic rangeionic selectionic tab(选项卡)ionic 网格(Grid)ionic 颜色ionic icon(图标)

ionic JavaScript

ionic 上拉菜单ionic 背景层ionic 下拉刷新ionic 复选框ionic 单选框操作ionic 切换开关操作ionic 手势事件ionic 头部和底部ionic 列表操作ionic 加载动作ionic 模态窗口ionic 导航ionic 平台ionic 浮动框ionic 对话框ionic 滚动条ionic 侧栏菜单ionic 滑动框ionic 加载动画ionic 选项卡栏操作

ionic 浮动框


$ionicPopover

$ionicPopover 是一个可以浮在app内容上的一个视图框。

可以实现以下功能点:

  • 在当前页面显示更多信息。
  • 选择一些工具或配置。
  • 在页面提供一个操作列表。

方法

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() { // 执行代码 }); }])

尝试一下 »

分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)