Ionic list with button and checkbox in same line - ionic-framework

I'm trying to have a ion-list with button and checkbox or radio at the end of the line.
That's my code without checkbox/radio:
<button ion-item (click)="editItem(i, item)">
<ion-avatar item-start>
<img [src]="item.photo" />
</ion-avatar>
<h2>{{item.name}}</h2>
<p>{{item.info}}</p>
</button>
It works and I can show any information about Item object.
If I add checkbox or radio my info disappear and the button click don't work (always checkbox change event trigger).
<button ion-item (click)="editItem(i, item)">
<ion-avatar item-start>
<img [src]="item.photo" />
</ion-avatar>
<h2>{{item.name}}</h2>
<p>{{item.info}}</p>
<ion-checkbox (ionChange)="fireEvent(i, $event)"></ion-checkbox>
</button>
How can I have a button and checkbox in same row ?

You can use the grid system to put elements on the same row:
<ion-grid>
<ion-row>
<ion-col>
<button ion-item (click)="editItem(i, item)">
<ion-avatar item-start>
<img [src]="item.photo" />
</ion-avatar>
<h2>{{item.name}}</h2>
<p>{{item.info}}</p>
</button>
</ion-col>
<ion-col>
<ion-checkbox (ionChange)="fireEvent(i, $event)"></ion-checkbox>
</ion-col>
</ion-row>
</ion-grid>
more info here:
https://ionicframework.com/docs/api/components/grid/Grid/

Related

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>

Button is not visible in ion-item when combined with inputs

I have an ion-list of food items to display wrapped in an ion-item, each of them is editable with three input fields (name, amount, unit), plus I would like to have a delete button at the left side of the row.
The inputs appear nicely within ion-item but I can't make the "trash" icon button to show up.
If I remove all the inputs, the button shows up.
What should I do to make both appear? Is it possible?
Here is the plunkr: http://plnkr.co/edit/JvHNEISfUCwcnujDB2jg?p=preview
Code:
<ion-content>
<ion-list>
<ion-item>
<button ion-button icon-only clear small>
<ion-icon name="trash"></ion-icon>
</button>
<ion-input type="text" value="peanut"></ion-input>
<ion-input type="number" value="1"></ion-input>
<ion-select>
<ion-option>oz</ion-option>
<ion-option>cup</ion-option>
<ion-option>glass</ion-option>
<ion-option>piece</ion-option>
</ion-select>
</ion-item>
</ion-list>
</ion-content>
ion-col and ion-row seemed to help, I wonder if this is the right way?
<ion-row>
<ion-col>
<button ion-button icon-only clear small>
<ion-icon name="trash"></ion-icon>
</button>
</ion-col>
<ion-col>
<ion-input type="text" value="peanut"></ion-input>
</ion-col>
<ion-col>
<ion-input type="number" value="1"></ion-input>
</ion-col>
<ion-col>
<ion-select>
<ion-option>oz</ion-option>
<ion-option>cup</ion-option>
<ion-option>glass</ion-option>
<ion-option>piece</ion-option>
</ion-select>
</ion-col>
</ion-row>

how to add a installed app shortcut to a listview in my ionic 3 app

Hello I am trying to make a app that when a user click's the add button opens another page that list's of all installed app's on that device then by clicking on a single app adds that app to the main page in a listview of my app and then the user can go back to the main page and click that app and it opens it from my app. I am using ionic 3 and am using the AppAvilability plugin to list all installed apps
here's my code for the main page:
<ion-header>
<ion-navbar>
<ion-buttons start>
<button ion-button icon-only solid>
<ion-icon name="add-circle"></ion-icon>
//add redirect to applist here
</button>
</ion-buttons>
<ion-title></ion-title>
<ion-buttons end>
<button ion-button icon-only solid>
<ion-icon name="remove-circle"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding id="page1">
<div class="spacer" style="height:30;" id="page1-spacer6"></div>
<ion-list id="page1-list1">
<ion-item color="none" href-inappbrowser="http://www.google.com" id="page1-list-item5">
<ion-avatar item-left>
<img src="assets/img/FUhCAggEQECSHctkev1s_web.png" />
</ion-avatar>
<h2>
Internet
</h2>
</ion-item>
</ion-list>
<div class="spacer" style="height:12;" id="page1-spacer1"></div>
<ion-list id="page1-list2">
<ion-item color="none" id="page1-list-item6">
<ion-avatar item-left>
<img src="assets/img/SWDHBJ2JRJyhl2rDAbPe_email.png" />
</ion-avatar>
<h2>
Email
</h2>
</ion-item>
</ion-list>
<div class="spacer" style="height:12;" id="page1-spacer2"></div>
<ion-list id="page1-list3">
<ion-item color="none" on-click="goToMath()" id="page1-list-item7">
<ion-avatar item-left>
<img src="assets/img/eRWr6of9Sq2eRPvM4LjM_math.png" />
</ion-avatar>
<h2>
Math
</h2>
</ion-item>
</ion-list>
<div class="spacer" style="height:12;" id="page1-spacer3"></div>
<ion-list id="page1-list4">
<ion-item color="none" on-click="goToScience()" id="page1-list-item8">
<ion-avatar item-left>
<img src="assets/img/Xtvlww5aS4SeDvBnE1FJ_sci.png" />
</ion-avatar>
<h2>
Science
</h2>
</ion-item>
</ion-list>
<div class="spacer" style="height:12;" id="page1-spacer4"></div>
<ion-list id="page1-list5">
<ion-item color="none" on-click="goToHandwriting()" id="page1-list-item9">
<ion-avatar item-left>
<img src="assets/img/eeisx650TqaSAMPn9EH4_handwrittin.png" />
</ion-avatar>
<h2>
Handwriting
</h2>
</ion-item>
</ion-list>
<div class="spacer" style="height:12;" id="page1-spacer5"></div>
<ion-list id="page1-list6">
<ion-item color="none" on-click="goToFlashcards()" id="page1-list-item10">
<ion-avatar item-left>
<img src="assets/img/noKqBQE1QbKdexCASz5g_flashcards.png" />
</ion-avatar>
<h2>
Flashcards
</h2>
</ion-item>
</ion-list>
<div>
<img src="assets/img/My3SIjXBSFoRJZG6yaWI_haQq7TIJRYeYrFNGbcvw_books.png" style="display:block;width:auto;height:auto;margin-left:auto;margin-right:auto;" />
</div>
</ion-content>
I'm new to ionic so any links/code samples on how to do would be amazing!
Thanks in advance!
Store all the apps in some sort of array. For example, you could make an array of object were each app has certain properties (a name etc.). Using *ngFor, you could list these in a view.
To push a page onto the navigation based on an entry you will want to import the NavController and NavParams. After that, create a page from the CLI using ionic g page appPage Then, you can inject the NavController and call .push('appPage') when the user clicks a button. Here is where you will want to push some data to the Navparams (navigation parameters) about which page was clicked. You can google "Angular Tour of Heroes" and follow the "detail view" guide they have on there so that you can associate each page in the list with a name of some sort.
After that, simply design your HTML and Typescript for the AppPage page to get a clean looking detailed pageview.

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 2 changing card text color

I've been trying to use ion-cards using ion dark theme, and I can't actually see the text;
I tried to change the CSS with this:
h2,p {
color:white;
}
and it's still black.
I took the code right from ionic documentation:
<ion-card class="col-md-4" *ngFor="let new of news;let i=index">
<ion-item>
<ion-avatar item-left>
<img [src]="new.image_url" *ngIf="new.image_url">
</ion-avatar>
<h2>TEST</h2>
<p>AA TEST</p>
</ion-item>
<ion-card-content>
<p>
TSET SUMMARY
</p>
</ion-card-content>
<ion-row>
<ion-col>
<button ion-button icon-left clear small>
<ion-icon name="thumbs-up"></ion-icon>
<div>12 likes</div>
</button>
</ion-col>
</ion-row>
</ion-card>
Any ideas?
You can overwrite the ionic variable itself. Navigate the ./theme/variables.scss and add
$card-ios-text-color(#fff);
$card-md-text-color(#fff);
$card-wp-text-color(#fff);
All the ionic variables can be found here for quick reference