How to display text under ion-avatar in ionic 5? - ionic5

In ionic 3 appliction, I use below code to display a group of images and the name of the image under the image.
<ion-list >
<ion-item>
<ion-row>
<ion-col *ngFor="let item of items">
<ion-avatar>
<img [src]="item.profilepic"/>
</ion-avatar>
<p>{{item.nameAbbreviation}}</p>
</ion-col>
</ion-row>
</ion-item>
</ion-list>
I use the same code in ionic 5. But the display shows some diffences: the ion-avatar image's size becomes much larger and the space between image and text becomes much wider.
I made changes as below, then the image size becomes the same as in ionic 3, but the text is shown at the same line of the image.
<ion-list >
<ion-row>
<ion-col *ngFor="let item of items">
<ion-item>
<ion-avatar>
<img [src]="item.profilepic"/>
</ion-avatar>
<p>{{item.nameAbbreviation}}</p>
<ion-item>
</ion-col>
</ion-row>
</ion-item>
</ion-list>
Can you tell me what is the correct code to display text under ion-avatar in ionic 5?

Hope you find your solution here.
Please use following code :
<ion-row style="border: 2px solid green">
<ion-col size="2">
<ion-avatar>
<img src="https://gravatar.com/avatar/dba6bae8c566f9d4041fb9cd9ada7741?d=identicon&f=y" style="border: 2px solid black;">
<span style="border: 2px solid red;">TExt Text Text</span>
</ion-avatar>
</ion-col>
<ion-col size="10" style="padding: 3em;"><b>IONAVATAR DEMO Image With Text</b></ion-col>
</ion-row>
Output :
RedBorder display the text and you can place your text content there.........!!!!!

Related

ion-option-buttons showing if i put ng-change on ion-toggle

Good day! Im fairly new to ionic and mobile dev. Im making a simple reminder app and Im implementing ion-toggle
Here what my code looks like,
<ion-item class="item-avatar" ng-repeat="med in meds.medications" >
<img ng-src={{med.medicine.image_url}} style="top: 25px;">
<div class="row">
<div class="col col-50 col-center">
<h2>{{ med.medicine.name }}</h2>
<p>{{ med.dose +' '+med.type }}</p>
<p style="font-weight: bold" >{{ med.time }}</p>
</div>
<div class="col" style="border: 0">
<ion-toggle ng-checked="!med.status" toggle-class="toggle-calm" style="border: 0;"> </ion-toggle>
</div>
</div>
<ion-option-button class="button-positive" ng-click="meds.showEditMed(med)">Edit</ion-option-button>
<ion-option-button class="button-assertive" ng-click="meds.showDeleteMed(med)">Delete</ion-option-button>
</ion-item>
I have a very weird problem, whenever I put ng-change on my ion-toggle, the option button shows up. Ive looked up the net for some solutions, none of which have this the same problem.
Here is an image of my problem
Thank you very much for your help
Use ng-model on ion-toggle, here is the sample code:
<ion-toggle ng-model="someVariable" ng-checked="!med.status" toggle-class="toggle-calm" style="border: 0;"> </ion-toggle>
ooops, my bad. I forgot to put ng-model on the ion-toggle.

how to make an ionic list scrollable?

im trying to make an ionic-list scrollable by adding ion-scroll but instead of the the ion-list being scrollable the entire page becomes scrollable. how do i make just the ionic-list scrollable? here's my code:
<ion-view title="Omnipay - Welcome" id="page5">
<ion-content padding="true" class="has-header">
<div>
<img src="img/omnipay_logo.jpg" style="display: block; width: 100%; height: auto; margin-left: auto; margin-right: auto;">
</div>
<h3 id="omnipayWelcome2-heading13" style="color:#000000;">My Info:</h3>
<h4 id="omnipayWelcome2-heading15" style="color:#000000;">Balance:</h4>
<h4 id="omnipayWelcome2-heading14" style="color:#000000;">Transaction History</h4>
<ion-scroll direction="xy" >
<ion-list can-swipe="listCanSwipe">
<ion-item ng-repeat="item in data1">
Date: {{item.date}}<br>Transaction: {{item.transaction}}<br>Merchant: {{item.merchant}}<br>Amount: {{item.amount}}
</ion-item>
</ion-list>
</ion-scroll>
<a ui-sref="menu.mainMenu" id="transactionHistory-button1" class="button button-positive button-block">Back</a>
<button class="button button-positive button-block" ng-click="refreshPage()">Refresh</button>
</ion-content>
</ion-view>
Give your <ion-scroll> directive a height attribute: Eg.
CodePen Demo / CodePen Full Page (Best seen on mobile view of the browser)
<ion-scroll style="height: 200px">
<ion-list>
<ion-item ng-repeat="item in items">{{item}}</ion-item>
</ion-list>
</ion-scroll>
ion-scroll doesn't exist anymore, div could be use instead
the above css could be actualized like the following
div[scrollx=true],div[scrolly=true] {
position: relative;
overflow: hidden;
}
div[scrollx=true] {
overflow-x: auto;
}
div[scrolly=true] {
overflow-y: auto;
}
<div scrolly="true" style="max-height:100px">
<!--content to scroll whose height exceeds 100px-->
</div>
This worked for me:
<ion-content [scrollEvents]="true">
<ion-list>
...
</ion-list>
</ion-content>
https://ionicframework.com/docs/api/content

Creating ion-search bar using ionic not using ionic 2

I created the application using as per below coding, I want to handle the list view with ionic search bar as per below image. Is it possible, If so suggest me some ideas or else code blog It would be helpful for me.
Note : As per below code, Searching was worked well but if the search happened its shows the text with matched list and even not matched list with an empty cell. So I want to handle the search like second snap mentioned below.
sample.html
<ion-view view-title="Call Lists">
<ion-content class="customListView" has-header="true">
<div class="bar bar-header item-input-inset">
<input type="search" placeholder=" Search" ng-model="searchValue"
style="width:100%; padding-left:11px;" />
</div>
<ion-list>
<ion-item class="item item-avatar item-icon-right" ng-repeat="item in callItems.objects" ng-click="doTask()" can-swipe="true">
<ion-option-button class="button-positive"
ng-click="doEdit()">
<i class="ion-more"></i>
</ion-option-button>
<img src="img/men.png">
<i class="icon ion-ios-arrow-right"></i>
<div ng-repeat="(key, value) in item.Fields | filter:searchValue">
<h3> {{value.Value}}</h3>
</div>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
Output :
I Want to do like below :
While adding the below line empty cell issues got fixed.
<ion-item class="item item-avatar item-icon-right" ng-repeat="item in callItems.objects | filter:searchValue" ng-click="doTask()" can-swipe="true">
Instead of
<ion-item class="item item-avatar item-icon-right" ng-repeat="item in callItems.objects " ng-click="doTask()" can-swipe="true">
Thing is I've given two ng-repeat as per my scenarios, So I've to set search filter for both.
If anyone having the ideas regarding the search activity as per mentioned in the second snap, Share me your ideas or code blog It would be helpful for me.

Ionic list is cut off at the bottom

I am displaying a normal list view getting data but the bottom is cut off.
In my css, I have: ]
.scroll {
height: 100%
}
My HTML is:
<ion-content scroll="true" ng-controller="CategoriesCtrl" overflow-scroll="true">
<ion-list>
<ion-item ng-repeat="category in categories | orderBy: 'id':true"
href="#/category/{{category.id}}"
class="item item-thumbnail-left catthumb list cat">
<img ng-src="{{category.acf.thumbnail.url}}" class="catthumb">
<span style="font-size: 21px; font-weight: 400;">{{category.name}}</span>
</ion-list>
</ion-content>
Here is the image:
You're missing the closing ion-item tag. It should be:
<ion-content scroll="true" ng-controller="CategoriesCtrl" overflow-scroll="true">
<ion-list>
<ion-item ng-repeat="category in categories | orderBy: 'id':true"
href="#/category/{{category.id}}"
class="item item-thumbnail-left catthumb list cat">
<img ng-src="{{category.acf.thumbnail.url}}" class="catthumb">
<span style="font-size: 21px; font-weight: 400;">{{category.name}}</span>
</ion-item>
</ion-list>
</ion-content>
This happen when we added another view level header or footer.
Simple solution is to add spacer div in the end of ur page with the height of ur page level header.
For more info

Swiper.js vertical sliding doesn't work in ionic on iphone

I've been trying to create a a mobile app with Ionic.
I am using slider.js to slide between certain DIVs.
The app was working properly until suddenly the vertical slider decided to not display itself. Completely invisible.
The strange part is that it is working 100% correctly on the browser in the ionic lab.However It does not work on my Iphone. I've tried using PhoneGap developer app and ionic view app , both of them same result , doesn't get displayed.
Another strange thing happens is that , If I change the swiper to be horizontal , it works.
Any help is appreciated.Thank you.
Here is my HTML code :
<div class="swiper-container swiper-container-v">
<div class="swiper-wrapper">
<div class="swiper-slide" ng-repeat="child in home.models[0].children" end-repeat>
<div class="card" style="border: 1px #D9D9D9 solid">
<div class="item item-text-wrap">
<ion-list>
<ion-item class=" item-avatar item-icon-right" type="item-text-wrap" href="#">
<h2 style="text-align: center"><b>{{ child.name | capitalizea}}</b></h2>
<p>15 / 35</p>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item class=" item-avatar item-icon-right" type="item-text-wrap" href="#" ui-sref="tab.profile-dashboard({id:child.manager.id})">
<img width="100%" ng-src="{{child.manager.image_path}}">
<h2 class="capitalizeff"> {{ child.manager.name}}</h2>
<p> {{ child.manager.title}}</p>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item class="item-avatar item-icon-right" type="item-text-wrap" href="#">
<img width="100%" ng-src="https://cdn2.iconfinder.com/data/icons/crystalproject/crystal_project_256x256/apps/keditbookmarks.png">
<h2>Achieve 100 goals</h2>
<p>35 / 100</p>
</ion-item>
<ion-item class="item-avatar item-icon-right" type="item-text-wrap" href="#">
<h2 style="text-align: center;padding-top: inherit">Food</h2>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
<ion-item class="item-avatar item-icon-right" type="item-text-wrap" href="#">
<h2 style="text-align: center;padding-top: inherit">fruits</h2>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
</ion-list>
</div>
</div>
</div>
</div>
</div>
Here is my JS code :
.controller('HomeCtrl', function ($scope, $rootScope) {
var vm = this;
var mySwiper = new Swiper('.swiper-container-v', {
slidesPerView: 1,
spaceBetween: 50,
direction: 'vertical',
observer: true
});
});
Here is the css :
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
}

Resources