用户名和密码的离子弹出模板

时间:2016-02-08 02:14:43

标签: javascript angularjs css3 jquery-mobile ionic-framework

我正在使用ionic制作移动应用。我想使用弹出窗口收集两个数据,用户名和密码。我查看了很多网站,它只显示了弹出窗口如何收集一个数据,但不是两个。另外,我想让弹出窗口变成紫色。我怎么能这样做?

$scope.create = function() {
    $scope.data = {}; 
  // An elaborate, custom popup
  var myPopup = $ionicPopup.show({
    template: '<input type="password" ng-model="data.one">',
    style: 'background-color:purple;',
    title: 'Enter Wi-Fi Password',
    scope: $scope,
    buttons: [
      { text: 'Cancel' },
      {
        text: '<b>Save</b>',
        type: 'button-balanced',
        onTap: function(e) {
          if ((!$scope.data.one)&&(!$scope.data.two)) {
            e.preventDefault();
          } else {
            return $scope.data;
          }
        }
      }
    ]
  });
}

1 个答案:

答案 0 :(得分:3)

您可以使用CodePen

实现此目的

这是一个工作示例

<强> HTML

  <script id="add-or-edit-cart.html" type="text/ng-template">

        <ion-modal-view>
            <ion-header-bar>
                <h1 class="title">{{ action }} Page</h1>
                <div class="buttons">
                    <button ng-click="deleteCart()" class="button button-icon icon ion-close"></button>
                </div>
            </ion-header-bar>
            <ion-content>
                <div class="list list-inset">
                    <label class="item item-input">
                      Dummy Text
                    </label>

                </div>

            </ion-content>
        </ion-modal-view>

    </script>

ng-click添加到页脚中的查看购物车

<ion-footer-bar  class="bar-footer btn-footer bar-light">
  <div class="row">
    <div class="col">
      <button ng-click="vm.showCart()" ng-controller="OverviewController as vm" class="button  button-block button-positive"> View cart Page </button>
    </div>
    <div class="col">
      <button class="button  button-block button-calm"> View checkout page </button>
    </div>
  </div>
</ion-footer-bar>

<强> JS

添加以下控制器

.controller('OverviewController', function ($scope, $ionicModal) {
    var vm = this;

    $ionicModal.fromTemplateUrl('add-or-edit-cart.html', {
        scope: $scope,
        animation: 'slide-in-up'
    }).then(function (modal) {
        $scope.modal = modal;
    });

    vm.showCart = function () {
        $scope.Cart = {};
        $scope.action = 'Cart';
        $scope.isAdd = true;
        $scope.modal.show();
    };




    $scope.deleteCart = function () {

        $scope.modal.hide();
    };

    $scope.$on('$destroy', function () {
        $scope.modal.remove();
    });

    return vm;

这里正在运作{{3}}