Scrolling wrapped text in an ion-list - html

I've been working on a list with scrollable content, but after several tests I found that the scollbar is considering only the image but not the wrapped text for item size. This causes truncating content at the bottom of the page.
Here's my code:
<ion-content ng-controller="categoriesCtrl" ng-switch on="categories.length > 0" has-bouncing="false">
<ion-refresher on-refresh="updateCategories()">
</ion-refresher>
<div ng-switch-when="true">
<ion-list type="card">
<a class="item item-thumbnail-right item-text-wrap" href="#" ng-repeat="category in categories">
<img ng-src="{{category.photo}}" />
<h2>{{category.name}}</h2>
<p class="item-text-wrap">{{category.description}}</p>
</a>
</ion-list>
</div>
</ion-content>
this is what I got, cannot scroll any further
Solutions?

It appears you're using a combination of the <ion-list> directive with the list CSS elements. Try using the <ion-list> with <ion-item> directive.
<ion-list>
<ion-item class="item-text-wrap item-thumbnail-right">
<img ng-src="{{category.photo}}" />
<h2>Name</h2>
<p>{{description}}</p>
</ion-item>
<ion-item class="item-text-wrap item-thumbnail-right">
<img ng-src="{{category.photo}}" />
<h2>Name</h2>
<p>{{description}}</p>
</ion-item>
</ion-list>
Here's the working demo.

Related

How keep the same header section in a Ionic app?

my Ionic applications has a bottom tabs, where I can choice different tab/page. Each tab/page has different top tabs, but I want to keep the some header sections for the entire app, where on the right there is the Logo of the App and on the right an ion-avatar, where when I click on them I can choice different user. How Can I achieve this?
<ion-header color="primary">
<ion-item color="primary">
<div width-50 item-start>
<img src="assets/icon/myLogo.png">
</div>
<div width-50 item-end>
<img src="assets/icon/avatar-icon.png">
</div>
</ion-item>
<ion-toolbar color="primary">
<ion-segment [(ngModel)]="topTab" (ionChange)="onTabChanged()">
<ion-segment-button value="send" >
<ion-icon color="light" title="Invia" name="send">Invia</ion-icon>
<ion-label>Invia</ion-label>
</ion-segment-button>
<ion-segment-button value="calendar" >
<ion-icon color="light" title="Inviate" name="calendar"></ion-icon>
<ion-label>Inviate</ion-label>
</ion-segment-button>
</ion-segment>
</ion-toolbar>
</ion-header>
<ion-content>...
How Can I achieve this? Also I'm not able to se the first image on the left and the second one on the right, where am I wrong?
You can create a custom header component and add the tag wherever you want.
For example:
#Component({
selector: 'my-header',
template: '<ion-header color="primary"> ... </ion-header>'
})
export class MyHeader{ ... }
and add <my-header> in the pages you want.
Regarding the images, you can use the grid system in Ionic.
<ion-grid>
<ion-row>
<ion-col>
<img src="assets/icon/myLogo.png">
</ion-col>
<ion-col>
<img src="assets/icon/avatar-icon.png">
</ion-col>
</ion-row>
</ion-grid>

How to work ion-item-sliding with *ngFor?

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

Hide div when add items - ionic framework

Im trying to hide specific div (empty state) when i add some item from add button, any ideas how can i do that easily?
Best Regards, Will.
page.html
<ion-content>
<!-- DIV ABOVE -->
<div class="center-div">
<img src="assets/imgs/noItem.svg" />
<div class="center">
<h1>Empty List</h1>
</div>
</div>
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content pullingIcon="arrow-dropdown" pullingText="Pull to refresh" refreshingSpinner="circles" refreshingText="Refreshing...">
</ion-refresher-content>
</ion-refresher>
<ion-list>
<button *ngFor="let item of items" ion-item (click)="goToItemDetail(crop)">
...
</ion-list>
<ion-fab right bottom>
<button ion-fab class="button-fab" (click)="addItem()">
<ion-icon name="add"></ion-icon>
</button>
</ion-fab>
</ion-content>
Yes, you can hide div with the help of *ngIf="condition"
<div class="center" *ngIf="items">
<h1>Empty List</h1>
</div>
or you can also check boolean varible on button like
// isVisible: boolean
addItem() {
this.isVisible = false;
}
<div class="center" *ngIf="!isVisible">
<h1>Empty List</h1>
</div>

how do remove underline in side-menu ionic 2

I've create a side menu.
and button inside it
<ion-content style="background-image: url(assets/imgs/background.jpg)" >
<div id="sideBody">
<ion-list>
<button menuClose ion-item *ngFor="let p of Func.getPages()" (click)="openPage(p, p.title)">
{{p.title}}
</button>
</ion-list>
</div>
</ion-content>
</ion-menu>
how to make underline inside menu not showing and how change color text menu?
<ion-list no-lines>
<button menuClose ion-item *ngFor="let p of Func.getPages()" (click)="openPage(p, p.title)">
{{p.title}}
</button>
</ion-list>
Simply by putting no-lines property in like above i had edited your code.

How to position this button on the right side?

I hope you can help me with this problem. Since yesterday I’ve been trying to position this green button on the right side. And things like margin don’t work:(
HTML
<ion-header>
<ion-toolbar color="rank">
<ion-searchbar (input)="getItems($event)"></ion-searchbar>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list-header>
Friends
</ion-list-header>
<ion-list>
<ion-item>
<ion-avatar item-start>
<img src="img/fri.jpg">
</ion-avatar>
<h1>JanePrincess</h1>
<h3>Iceland, Reykjavik </h3>
<button ion-button color="rank" round>Add</button>
</ion-item>
</ion-list>
</ion-content>
Here the button
Just like you can see in the docs, you can achieve that by using the item-end attribute in the button:
<ion-list>
<ion-item>
<ion-avatar item-start>
<img src="img/fri.jpg">
</ion-avatar>
<h1>JanePrincess</h1>
<h3>Iceland, Reykjavik </h3>
<button ion-button color="rank" round item-end>Add</button>
</ion-item>
<!-- ... -->
</ion-list>
Use ion-item padding.
<ion-item padding>
<button default ion-button item-right color="rank" round >Add</button>
</ion-item>
You can use css as well.
I hope you made the CSS file for the above problem, so try putting the following code into it:
button {
color:green;
position:relative;
top:-43px;
left: 410px;
}
To adjust the position of the button horizontally, just adjust left position accordingly.