|
本帖最后由 git 于 2016-5-11 01:31 编辑
- angular.module("app", ['ionic'])
- .controller("controller", function($scope,$ionicPopup,$compile) {
-
- $scope.click = function() {
- $ionicPopup.show({
- //title: "<a ng-click='close()'>已报名会员</a>",
- scope: $scope,
- buttons: [
- { text: 'Cancel' },
- ]
- });
-
- var title = "<button ng-click='close()'>关闭</button>";
- var stack = $ionicPopup._popupStack;//获取所有的弹出层列表
- if(stack.length>0){
- var popup = stack[stack.length-1];//最后一个是当前打开的popup
- popup.scope.close = function(){
- popup.responseDeferred.resolve();//关闭当前弹出层
- }
- var $btn = $compile(title)(popup.scope);//compile的scope为popup的scope
- var $parent = popup.element;
- angular.element('.popup-head', $parent).append($btn);//将compile好的元素放到popup-head上
- }
- }
- })
复制代码 http://codepen.io/wangchuan/pen/ONqVVd
可以这样来写, 代码作用是在标题上加入一个可以关闭弹出层的按钮 |
|