I doing thank you page in my project. in success call it will display ORDER DETAILS and Delivery Details & Failure call it will display only ORDER DETAILS..
Success call is working fine but failure call not displaying order details...
below is my html code..
<!--
Generated template for the ThankYouPage page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>Order Summary</ion-title>
<ion-buttons end>
<button ion-button icon-only>
<ion-icon name="share"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<div *ngIf="orderSuccess">
<ion-item no-lines>
<ion-row>
<ion-icon ios="ios-checkmark-circle" md="md-checkmark-circle" class="success"></ion-icon>
</ion-row>
<ion-row class="text-center">
<p>Thank you. Your order has been</p>
</ion-row>
<ion-row class="text-center"><p>Successfully Placed.</p></ion-row>
</ion-item>
<hr>
</div>
<div *ngIf="orderFailure">
<ion-item>
<ion-row>
<ion-icon ios="ios-close-circle" md="md-close-circle" class="failure"></ion-icon>
</ion-row>
<ion-row class="text-center">
<p>Sorry! Failed to place your order.</p>
</ion-row>
<ion-card>
<ion-card-content>
Your Order could not be completed because of the-"System Generated Issue"
</ion-card-content>
</ion-card>
</ion-item>
</div>
<ion-item *ngFor=" let item of orderDetailsArray">
<div class="div"> Order Details </div>
<ion-row *ngIf="orderSuccess">
<ion-col class="down">Order Date</ion-col><br>
<ion-col class="down">{{item.date_added | date:'MMM-dd-yyyy'}}</ion-col>
</ion-row>
<ion-row *ngIf="orderSuccess">
<ion-col>Order number</ion-col><br>
<ion-col>{{item.order_id}}</ion-col>
</ion-row>
<hr>
<ion-row class="row">
<ion-col class="lightbold">Order Total</ion-col><br>
<ion-col class="bold">$ {{item.total}}</ion-col>
</ion-row>
<ion-row class="pay">
<ion-col>Payment method:</ion-col><br>
<ion-col class="color">{{item.payment_method}}</ion-col>
</ion-row>
</ion-item>
<div *ngIf="orderSuccess">
<ion-item *ngFor=" let item of orderDetailsArray">
<div class="div"> Delivery Details </div>
<div class="font">
<div>{{item.shipping_firstname}} {{item.shipping_lastname}}</div>
<div>{{item.shipping_address_1}} , {{item.shipping_address_2}}</div>
<div>{{item.shipping_city}}, {{item.shipping_postcode}}</div>
<div>{{item.shipping_zone}}</div>
<div class="phone">
<ion-icon ios="ios-call" md="md-call" item-left></ion-icon>
<span>{{item.telephone}}</span>
</div>
<div class="mail">
<ion-icon ios="ios-mail" md="md-mail" item-left></ion-icon>
<span>{{item.email}}</span>
</div>
</div>
</ion-item>
</div>
</ion-content>
<ion-footer>
<ion-toolbar color="primary">
<div *ngIf="orderSuccess">
<ion-row class="center" (click)="submit();"> GO BACK HOME </ion-row>
</div>
<div *ngIf="orderFailure">
<ion-row class="center" (click)="submit();"> GO BACK HOME </ion-row>
</div>
</ion-toolbar>
</ion-footer>
below is my ts file...
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
import { Rest } from '../../providers/network/rest';
import { Logger } from '../../providers/logger/logger';
/*
Generated class for the ThankYou page.
See http://ionicframework.com/docs/v2/components/#navigation for more info on
Ionic pages and navigation.
*/
#Component({
selector: 'page-thank-you',
templateUrl: 'thank-you.html'
})
export class ThankYouPage {
orderDetailsArray = [];
public orderSuccess:boolean =false;
public orderFailure:boolean =false;
constructor(public navCtrl: NavController,
public rest: Rest,
public logger: Logger) {}
ionViewDidLoad() {
this.rest.get('/getOrder&order_id=0')
.subscribe((result) => {
console.log("checking getOrder"+JSON.stringify(result));
if(result.status == '1'){
console.log("success of getOrder");
this.orderDetailsArray=result.order;
this.orderSuccess=true;
}
else{
console.log("error of getOrder");
this.orderFailure = true;
}
})
}
submit(){
//this.navCtrl.setRoot(HomePage,{});
}
notSubmit(){
//this.navCtrl.push(PaymentPage,{});
}
}
Success call is working fine but failure call is not displaying order details...
It's because you are only setting the orderDetailsArray if your result.status is 1!
You should do it like this:
ionViewDidLoad() {
this.rest.get('/getOrder&order_id=0')
.subscribe((result) => {
console.log("checking getOrder"+JSON.stringify(result));
this.orderDetailsArray=result.order; // <-- place it here !
if(result.status == '1') {
console.log("success of getOrder");
this.orderSuccess=true;
}
else {
console.log("error of getOrder");
this.orderFailure = true;
}
});
}
You can also use this to convert result.status into Integer.Try this because status should always come in integer type and you are using string.I hope it will help you.
if(((result.status)*1) == 1) {...}
Related
I have an Ionic 6 / angular 13 project which I am working with some modals. My modals have multiple breakpoints and they contains a card with header and content and also two buttons. I want these buttons to be visible at any breakpoints but always be at the bottom of the page view.
modal config:
const modal = await this.modalController.create({
component: MyComponent,
backdropBreakpoint: 0.1,
initialBreakpoint: 0.5,
breakpoints: [smallestBreakPoint, 0.5, 0.9]
})
MyComponent template:
<ion-card style="background-color: white; height: 90%;">
<ion-card-header class="pb-0 pt-2">
<ion-card-title>
...
</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-item lines="none">
...
</ion-item>
<ion-item lines="none" (click)="..." button>
...
</ion-item>
<ion-row>
<ion-col class="text-center">
<ion-button expand="block" class="custom-button" color="light">
...
</ion-button>
</ion-col>
<ion-col class="text-center" size="8">
<ion-button expand="block" class="custom-button" (click)="...">
...
</ion-button>
</ion-col>
</ion-row>
</ion-card-content>
</ion-card>
I tried changing <ion-row> and <ion-card> position and offset to everything, and none of them did the trick. Also I tried <ion-footer>. Please note that the card div is larger than it should be because it should open fully on 0.9 breakpoint.
Expected output:
How can I do this?
Thanks in advance!
I'm trying to implement the ion-item-sliding option to create an ion-card that can slide within a flex-box grid. Unfortunately, it doesn't seem to work very well.
To be specific, nothing actually happens! No matter what direction I swipe from, there is no indication of a swipe taking place.
Here is what I have so far:
<ion-content padding>
<ion-grid>
<ion-row>
<ion-col col-6 offset-sm-3 *ngFor = "let list of listRef | async">
<ion-item-sliding>
<ion-item>
<ion-card>
<img *ngIf="list.color=='#f55f7c'" src="data:image/png;base64,iVBORw0dsfladj=">
<img *ngIf="list.color=='#ffcb53'" src="data:image/png;base64,iVB5CYII=">
<img *ngIf="list.color=='#85dec8'" src="data:image/png;base64,iVBORw0KGgoAAAANSU=">
</ion-card>
</ion-item>
</ion-item-sliding>
<ion-item-options side="left">
<button ion-button>Favorite</button>
<button ion-button color="danger">Share</button>
</ion-item-options>
</ion-col>
<button id="add-bttn" ion-button [navPush]="goNew"><ion-icon name="add"></ion-icon></button>
</ion-row>
</ion-grid>
</ion-content>
I've tried it with the *ngFor statement placed within the tag and in the tag. No go.
Any help would be enlightening!
Just like you can see in the Docs, the ion-item-options should be within the ion-item-sliding element. Besides, the items should be placed inside of an ion-list container.
So something like this should work:
<ion-content padding>
<ion-list> <!-- Here I've added the ion-list -->
<ion-row>
<ion-col col-6 offset-sm-3 *ngFor = "let list of listRef | async">
<ion-item-sliding>
<!-- Item -->
<ion-item>
<ion-card>
<img src="https://randomuser.me/api/portraits/men/51.jpg">
</ion-card>
</ion-item>
<!-- Options -->
<ion-item-options side="left">
<button ion-button>Favorite</button>
<button ion-button color="danger">Share</button>
</ion-item-options>
</ion-item-sliding> <!-- This includes the options-->
</ion-col>
<button id="add-bttn" ion-button [navPush]="goNew">
<ion-icon name="add"></ion-icon>
</button>
</ion-row>
</ion-list>
</ion-content>
Stackblitz project
I am using a template I bought recently to build my ionic + angular app. My problem is that I am new to angular and I am trying to redirect the user when the click a button. I've been researching and I got the point where it detects the click but doesn't redirect. I tried importing "router" and other troubleshooting steps but it's not working for me. Here is my html, and ts file.
html
<!--Theme Google Card - Full Image Cards-->
<ion-content padding-top>
<ion-grid no-padding>
<ion-row *ngIf="data != null">
<ion-col col-12 col-md-6 col-lg-6 *ngFor="let item of data.items;let i = index">
<ion-card text-left box-shadow margin-bottom>
<!--Card Image-->
<div card-image>
<img [src]="item.image" />
<div watch-now text-center (click)="onEvent('onItemClick', item, $event)">
<button ion-button button-icon icon-start>
<ion-icon icon-small [name]="item.icon"></ion-icon>
{{item.iconText}}
</button >
</div>
</div>
<!--Card descriptiom-->
<ion-card-content>
<ion-card-title text-center>
<!--Card Subtitle-->
<h1 card-title>{{item.title}}</h1>
<!-- Icon Rating Star -->
<ion-icon *ngFor="let star of item.ratingStar.iconsStars; let i = index" (click)="onStarClass(item.ratingStar.iconsStars, i, $event)">
<i icon-small *ngIf="star.isActive" class="icon {{star.iconActive}}"></i>
<i icon-small *ngIf="!star.isActive" class="icon {{star.iconInactive}}"></i>
</ion-icon>
<!-- Reviews Star -->
<span span-medium>{{item.reviews}}</span>
<!--Card Body Text-->
<p margin-top card-body-text>{{item.description}}</p>
</ion-card-title>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>
</ion-content>
TS
import { Component, Input, ViewChild } from '#angular/core';
import { IonicPage, Content } from 'ionic-angular';
#IonicPage()
#Component({
selector: 'google-card-layout-1',
templateUrl: 'google-card.html'
})
export class GoogleCardLayout1 {
#Input() data: any;
#Input() events: any;
#ViewChild(Content)
content: Content;
slider = {};
constructor() { }
slideHasChanged(slider, index): void {
this.slider[index] = slider;
if (2 == slider._activeIndex) {
if (this.data.items) {
this.data.items.splice(index, 1);
} else {
this.data.splice(index, 1);
}
}
}
onStarClass(items: any, index: number, e: any) {
if (e) {
e.stopPropagation();
}
for (var i = 0; i < items.length; i++) {
items[i].isActive = i <= index;
}
this.onEvent("onRates", index, e);
};
onClickEvent(index): void {
if (this.slider[index]) {
this.slider[index].slidePrev(300);
}
}
onEvent(event: string, item: any, e: any) {
if (e) {
e.stopPropagation();
}
if (this.events[event]) {
this.events[event](item);
}
}
}
Firstly you have to declare your route in your routing file in my case i have one newly created component so i update my route as follow
{
path: 'admin',
canActivate: [AuthGuard],
loadChildren: './pages/admin/admin.module#AdminModule'
},
After that there are two method to navigate,
1) <button [routerLink]="['/admin']" ion-button button-icon icon-start>
2) <button (click)="navigate()" ion-button button-icon icon-start>
and in your ts file add code
navigate() {
this.router.navgateURL(['/admin']);
}
Try:
<button [routerLink]="['/path']" ion-button button-icon icon-start>
This is my html code
<ion-searchbar [(ngModel)]="data" placeholder="Airlines" (ionInput)="getAirlines($event)">
</ion-searchbar>
<ion-list *ngIf="data">
<ion-item *ngFor="let item of airlines" (click)="airlinesClicked($event, item)">
<button ion-button item-start clear style="margin-right:2%; width:10%;height:10%" no-padding>
<img no-padding src="{{item.logo}}">
</button>
{{item.name}}
</ion-item>
</ion-list>
Iam trying to get searched result as list by filtering by each letters. While i am searching my list pushing my below contents down in my page. So i like to get my item as popover. Can anyone help me to get my result......
Thanks in advance
I'm not pretty sure but maybe when the data is ready you can create a popover controller and the resize the page.
import { PopoverController } from 'ionic-angular';
#Component({})
class yourClassName {
constructor(public PopOverCtrl: PopoverController) {}
presentPopover(event) {
let popover = this.popoverCtrl.create(ListPage);
popover.present({
ev: event
});
}
}
more details on Ionic website
You can use bootstrap for the following class tags
and create a custom list popover on ion-searchbar
<ion-row>
<ion-searchbar
(ionChange)="getAirlines($event)"
[(ngModel)]="data" placeholder="Airlines"
></ion-searchbar>
</ion-row>
<ion-row>
<ul
class="list-group position-absolute px-2 search-list w-100 rounded-2 shadow-sm"
*ngIf="data">
<li
*ngFor="let item of airlines"
class="list-group-item"
(click)="airlinesClicked($event,item)">
{{item.name}}
</li>
</ul>
</ion-row>
-----css
.search-list{
z-index: 9;
max-height: 150px;
overflow-y: auto;
}
I have a problem I implemented a search bar and now there is a space between the bar and the content (profiles). How can I get rid of this space? I know there should be the Items to be searched, but I have other items, the profiles. Do I have to implement them there, where the space is.
How can I position the green button on the right side, central. I tried it with margin but that didn’t work.
HTML:
<ion-header>
<ion-navbar color="rank">
<ion-title>
friends
</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-content>
<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
<ion-list>
<ion-item *ngFor="let item of items">
{{ item }}
</ion-item>
</ion-list>
</ion-content>
<ion-list>
<ion-item>
<button ion-button color="rank" round>Add </button>
<ion-avatar item-start>
<img src="img/fri.jpg">
</ion-avatar>
<h1>JanePrincess</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
<ion-item>
<ion-avatar item-start>
<img src="img/hot.jpg">
</ion-avatar>
<h1>Dean</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
<ion-item>
<ion-avatar item-start>
<img src="img/top.jpg">
</ion-avatar>
<h1>Wayne</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
<ion-item>
<ion-avatar item-start>
<img src="img/loc.jpg">
</ion-avatar>
<h1>Pieii</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
<ion-item>
<ion-avatar item-start>
<img src="img/top.jpg">
</ion-avatar>
<h1>Dude</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
<ion-item>
<ion-avatar item-start>
<img src="img/fri.jpg">
</ion-avatar>
<h1>de9md</h1>
<h3>Iceland, Reykjavik </h3>
</ion-item>
</ion-list>
</ion-content>
TypeScript:
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
#Component({
selector: 'lions-home',
templateUrl: 'lions.html'
})
export class LionsPage {
items;
constructor(public navCtrl: NavController) {
this.initializeItems();
}
initializeItems() {
this.items = [
];
}
getItems(ev) {
// Reset items back to all of the items
this.initializeItems();
// set val to the value of the ev target
var val = ev.target.value;
// if the value is an empty string don't filter the items
if (val && val.trim() != '') {
this.items = this.items.filter((item) => {
return (item.toLowerCase().indexOf(val.toLowerCase()) > -1);
})
}
}
}
You have an extra <ion-content> above your searchbar.