ionic three display one div at a time - ionic-framework

have divided my form into divs on one ionic html page want to display one at a time, navigate until submit any help, my form is somehow like this, the first should display by default but the other divs should be displayed on clicking next
<div id="formPart1">
<ion-row>
<label>select date</label>
<ion-input type="date" ng-model="date"></ion-input>
<button ion-button full ng-click="showNext()">Next</button>
</ion-row>
</div>
<div id="formPart2">
<ion-row>
<label>select date</label>
<ion-input type="name" ng-model="name"></ion-input>
</ion-row>
</div>

In this case, i suggest you to use ion-slides. Distribute form elements to the slides. and lock swipe on page load and only change to next slide on Next button click.
Do this to lock swiping
ionViewDidLoad() {
console.log('ionViewDidLoad ServicePage');
this.slides.lockSwipes(true);
}
and on Next button click
goToSlide(slideNo) {
this.slides.lockSwipes(false);
this.slides.slideTo(slideNo, 500);
this.slides.lockSwipes(true);
}

So, First of all you have to write the code like this
<div id="formPart1">
<ion-row>
<ion-label>select date</label>
<ion-input type="date" [(ngModel)]="date"></ion-input>
<button ion-button full (click)="showNext()">Next</button>
</ion-row>
</div>
<div id="formPart2" [hidden]="!YOUR_VARIABLE">
<ion-row>
<ion-label>select date</label>
<ion-input type="name" [(ngModel)]="name"></ion-input>
</ion-row>
</div>
in the show showNext() method you have to make the variable true, like this
showNext() {
this.YOUR_GLOBAL_VARIABLE = true
}
Hope this will help you !!!

Related

Ripple effect is firing on scroll

I'm getting the ripple effect to fire on touch (scroll) and not on click like it should be (guessing). This is happening either on ion-ripple-effect tag or in an ionic tag that has the ripple effect by default (like ion-item).
Here is a snippet of my code using the ion-ripple-effect tag:
<ion-row class="dash ion-margin-top">
<ion-col size-xs="6" size-sm="4" size-md="3" *ngFor="let item of dash">
<div class="box shadow">
<div class="content ion-activatable" routerLink="{{item.route}}">
<ion-icon name="{{ item.icon }}" color="primary"></ion-icon>
<ion-label color="dark">{{ item.name }}</ion-label>
<ion-ripple-effect></ion-ripple-effect>
</div>
</div>
</ion-col>
</ion-row>
Does anyone have encountered this, and if so, knows who to solve it?
Thanks in advance.

How to disable the button until radio button is checked in Ionic

I am working in the Ionic App and In that I have some list items with the radio button and at the bottom of the page, I have the checkout button. I want to disable the button until the user checked one of the item.
This is my shipping.html:
<ion-content padding>
<ion-grid>
<ion-row>
<ion-col col-12>
<ion-list radio-group>
<ion-item *ngFor="let itm of shippingdetails">
<ion-radio item-start value="{{itm.id}}"></ion-radio>
<ion-label>
<h2>{{itm.name}}</h2>
<p>{{itm.mobile}}</p>
<p>{{itm.state}}, {{itm.city}}</p>
<p>{{itm.address}}</p>
<p>Pincode: {{itm.pincode}}</p>
</ion-label>
<button ion-button outline item-end class="myedit22" (click)="editshipping(itm)">
<ion-icon name="create"></ion-icon>
</button>
<button ion-button outline item-end class="dele22" (click)="removeshipping(itm.id)">
<ion-icon name="ios-trash-outline"></ion-icon>
</button>
</ion-item>
</ion-list>
</ion-col>
<ion-col col-12 style="text-align: right;">
<button (click)="presentProfileModal()" class="myaddto22" ion-button square item-right>
Add Address
</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
<ion-footer class="single-footer" style="bottom: 51px; background-color: #fff;">
<ion-grid>
<ion-row>
<ion-col class="addCart">
<button class="myaddto22" [disabled]="!value" full ion-button round="true">
Make Payment
</button>
</ion-col>
</ion-row>
</ion-grid>
</ion-footer>
In this html, I am showing the items with the radio button and the checkout button at the bottom of the page but the problem is that, I am not able to disable the bottom button until the user checks the radio button.
In this, I am showing the items with the radio button and I have the button at the bottom. It will disable until the user select the item but the problem is that when the user select the item after that the button is not clickable.
Any help is much appreciated.
Seems like you need to store the selected radio button in a model, and then set your disabled flag based on that.
<ion-list radio-group [(ngModel)]="yourSelectedRadioValue">
...
<button class="myaddto22" [disabled]="!yourSelectedRadioValue" full ion-button round="true">
Make Payment
</button>

dynamic forms in Ionic 3

I'm learning Ionic 3 and I want create a dynamic form.
A dynamic form for me is a form that increases when I press a FAB button (like alarm native app in Android), I read dynamic forms in angular page but I think it's not what I'm looking for.
This is my code, but I think my base idea is correct, it's possible create something like this in Ionic 3?
<ion-list id="horario-list9">
<ion-item-divider color="light" id="horario-list-item-divider3">
<ion-list-header>
<h2>{{titles[0]}}</h2>
</ion-list-header>
</ion-item-divider>
<ion-item id="horario-range1">
<ion-range style="padding-left:0px" [(ngModel)]="quantity1" min="0" max="6" step="1" color="balanced" value="0" name="ration1">
<ion-icon range-left>
<img src="assets/imgs/cup.svg" alt="" height="40px" width="40px">
</ion-icon>
<ion-label range-right>
<div *ngIf="quantity1; else other_quantity1">
<p style="font-size:40px;color:#AED581">{{quantity1/2}}</p>
</div>
<ng-template #other_quantity1>
<p style="font-size:40px;color:black">0</p>
</ng-template>
</ion-label>
</ion-range>
</ion-item>
<ion-item>
<ion-label>
<ion-icon name="md-time" style="font-size:50px"></ion-icon>
</ion-label>
<ion-datetime style="font-size:40px" displayFormat="HH:mm" pickerFormat="HH mm" [(ngModel)]="event.timeStarts1"></ion-datetime>
</ion-item>
<div class="spacer" style="width:300px;height:30px;" id="horario-spacer6"></div>
<ion-fab center>
<button ion-fab color="secondary"><ion-icon ios="ios-add" md="md-add"></ion-icon></button>
</ion-fab>
</ion-list>
This look like this My form in Safari
I want create a dynamic form, I need when I press my green button add new ion-item in my list, it's possible? Angular documentation failed to explain this question

ionic2 How to put an element outside of modal

I want to add an element outside of modal using Ionic2 like the image below.
The area surrounded by blue border is the element that I want to add.
The area surrounded by red border is the custom modal that I have created.
Custom Modal.html
<ion-header>
<ion-navbar class="select-header">
<ion-buttons left (click)="close()">
<button ion-button>
<img class="close" src="assets/images/close.png"/>
</button>
</ion-buttons>
<ion-title>{{title}}</ion-title>
</ion-navbar>
</ion-header>
<ion-content class="region-selection">
<div class="select-all">
<img class="selection not-selected" src="assets/images/region/check_none.png"/>
<span>{{title}}</span>
</div>
<div class="select-region">
<ion-row class="regions-row" *ngFor="let row of rowsArray; let last = last" [ngClass]="{ last: last }">
<ion-col *ngFor="let region of regions | slice:(row*3):(row+1)*3">
<img class="selection not-selected" src="assets/images/region/check_none.png"/>
<span [innerHtml]="region"></span>
</ion-col>
</ion-row>
</div>
</ion-content>
Try placing all your items inside the ion-content and remove the ion-header to have a structure like this
<ion-content class="region-selection">
<div class="outside-element">
<!--element outside of modal-->
</div>
<!--This is your modal header wrapper-->
<div class="modal-header">
<ion-buttons left (click)="close()">
<button ion-button>
<img class="close" src="assets/images/close.png" />
</button>
</ion-buttons>
<ion-title>{{title}}</ion-title>
</div>
<!--This is your modal header wrapper-->
<div class="modal-content">
<div class="select-all">
<img class="selection not-selected" src="assets/images/region/check_none.png" />
<span>{{title}}</span>
</div>
<div class="select-region">
<ion-row class="regions-row" *ngFor="let row of rowsArray; let last = last" [ngClass]="{ last: last }">
<ion-col *ngFor="let region of regions | slice:(row*3):(row+1)*3">
<img class="selection not-selected" src="assets/images/region/check_none.png" />
<span [innerHtml]="region"></span>
</ion-col>
</ion-row>
</div>
</div>
</ion-content>
Now you can use css to style and position the elements using the classes .outside-element , .modal-header , .modal-content
Also, make sure to set your background-color to transparent

Ionic: Focusing on input field on sub-header makes keyboard hide list-elements

I'm working on an Ionic project and in one of our views we have an input field in the sub-header. Using this input field a user can search for other users which are displayed in an ion-list.
The problem I'm experiencing is that when the keyboard appears it's actually hiding part of the ion-list. After reading the Keyboard documentation from the Ionic docs, I believe the problem is caused because the sub-header input field and the ion-list are not part of the same scrollable area.
Is there any way I can solve this issue?
Here are the relevant parts of the code:
<ion-header-bar align-title="left" class="bar-light bar-subheader item-input-inset">
<div class="item-input-wrapper">
<i class="icon ion-ios-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="searchUsers" ng-change="showUsersSuggestions($event);" ng-focus="enableSearch(true)" ng-blur="enableSearch(false)">
<button class="button button-clear clear-search icon ion-ios-close-empty" ng-click="clearSearch()"></button>
</div>
</ion-header-bar>
<ion-content>
<ion-list can-swipe="true" ng-if="showSearchResults">
<ion-item class="item item-divider list-result" style="border-top:0;">
Search results
</ion-item>
<ion-item class="item item-avatar item-icon-right item-text-wrap list-result" ng-show="searchUsers && searchUsers.length >= 3 && usersSuggestions" ng-repeat="f in usersSuggestions">
<img ng-src="{{getAvatarUrl(f)}}" width="40" height="40" ng-click="showProfileInfo(f)">
<h2 ng-show="f.displayName" ng-click="showProfileInfo(f)">{{f.displayName}}</h2>
<p ng-click="showProfileInfo(f)">{{f.email}}</p>
</ion-item>
</ion-list>
......
</ion-content>
The only way i found to solve this is to close the keyboard on content touch event..
<ion-content class="has-subheader" on-touch="hideKeyboard()">
...
</ion-content>
scope.hideKeyboard = function() {
$cordovaKeyboard.close()
};
...
</ion-content>
<div keyboard-attach>
</div>
</ion-view>
I just added this div with keyboard-attach. The ionic documentation says keyboard-attach works just with a footer but it worked for me. I tested on iOS9.