Ionic Text color change onclick - ionic-framework

I'm a beginner in Ionic 3.
I have a 4 text in same color, I'm trying to make when I click on the 4 text at for time I want to change color.
Example
I click on 1st text, then I want to change it black color
I click on text 2, then I want to change black color and 1st text is set a default color,
Please help me to fix this issue
<div class="row">
<div class="col right-border">
<div text-center>
<h2 class="main-one" >$ 2,300</h2> <p class="main-txt-home">Today's Revenue</p>
</div>
</div>
<div class="col bottom-border">
<div text-center>
<h2 class="main-one">$ 53,100</h2><p class="main-txt-home">Expected Revenue for this month</p>
</div>
</div>
</div>
<div class="row">
<div class="col top-border">
<div text-center>
<h2 class="main-one">12</h2><p class="main-txt-home"> Bookings taken today</p>
</div>
</div>
<div class="col left-border">
<div text-center>
<h2 class="main-one">68%</h2><p class="main-txt-home">Total Monthly occupancy</p>
</div>
</div>
</div>
</div>

You can use [ngClass] attribute to achieve this. This can be used to dynamically return the class name as per the last clicked text. The code will be something like below.
<div class="row">
<div class="col right-border">
<div text-center [ngClass]="getTextColor('text1')" (click)="setSelectedText('text1')">
<h2 class="main-one" >$ 2,300</h2> <p class="main-txt-home">Today's Revenue</p>
</div>
</div>
<div class="col bottom-border">
<div text-center [ngClass]="getTextColor('text2')" (click)="setSelectedText('text2')">
<h2 class="main-one">$ 53,100</h2><p class="main-txt-home">Expected Revenue for this month</p>
</div>
</div>
</div>
<div class="row">
<div class="col top-border">
<div text-center [ngClass]="getTextColor('text3')" (click)="setSelectedText('text3')">
<h2 class="main-one">12</h2><p class="main-txt-home"> Bookings taken today</p>
</div>
</div>
<div class="col left-border">
<div text-center>
<h2 class="main-one">68%</h2><p class="main-txt-home">Total Monthly occupancy</p>
</div>
</div>
</div>
In controller
private selecteTextId :string;
setSelectedText(textId:string) {
this.selecteTextId = textId;
}
getTextColor(textId:string):string{
return this.selecteTextId == textId? "highlight-color" : "";
}
In scss file
.highlight-color {
color:blue;
}

Related

Div is not opening below particular ngFor in Angular 6

I am iterating ngFor in angular 6. When i am clicking on button a div should open beside row of that particular button but it is opening below ngFor like this
I want to make it open for that partcular row and below that.
<app-filter></app-filter>
<div class="bg-white" *ngFor="let data of dashboardData">
<div class="container-fluid">
<div class="center-align row">
<div class="col-sm-12">
<div class="block col-sm-2">
{{data.firstname}}{{data.lastname}}
</div>
<div class="block_l col-sm-3">
<span class="light_small">68%</span>
{{data.stage}}
</div>
<div class="block_l col-sm-1">
Customer
</div>
<div class="block_l col-sm-1">
<img src="assets/images/call.png">
</div>
<div class="block_l col-sm-1">
<img src="assets/images/mail.png">
</div>
<div class="block_l col-sm-2">
<span class="status_color"><b>.</b></span>
Paused
</div>
<div class="block_l col-sm-2">
<a class="btn button_css" (click)="openLayout=!openLayout">verify Details</a>
</div>
</div>
</div>
</div>
<div class="bg-loader"></div>
<div class="container" [hidden]="openLayout">
<div class="row">
<app-form-layout></app-form-layout>
<app-form-desc></app-form-desc>
</div>
</div>
</div>
Now it is coming like this
Desired behavior will be like this It's like accordian on click it should open below that row and rest of below rows will be shifted downwards
The problem resides into openLayout variable that is shared for all your rows.
You need one openLayout for each row. you can add it dinamically to your data like this:
<div class="bg-white" *ngFor="let data of dashboardData">
<div class="container-fluid">
<div class="center-align row">
<div class="col-sm-12">
<div class="block col-sm-2">
{{data.firstname}}{{data.lastname}}
</div>
<div class="block_l col-sm-3">
<span class="light_small">68%</span>
{{data.stage}}
</div>
<div class="block_l col-sm-1">
Customer
</div>
<div class="block_l col-sm-1">
<img src="assets/images/call.png">
</div>
<div class="block_l col-sm-1">
<img src="assets/images/mail.png">
</div>
<div class="block_l col-sm-2">
<span class="status_color"><b>.</b></span>
Paused
</div>
<div class="block_l col-sm-2">
<a class="btn button_css" (click)="data.openLayout=!data.openLayout">verify Details</a>
</div>
</div>
</div>
</div>
<div class="bg-loader"></div>
<div class="container" [hidden]="data.openLayout">
<div class="row">
<app-form-layout></app-form-layout>
<app-form-desc></app-form-desc>
</div>
</div>
</div>
At the beginning it will be false because undefined is like false.

Ionic 1 card view show two rows

I need to show two rows of data in Ionic 1 list card view but i am not been able to achieve this. I have used two div to add two rows but its not working.
<div class="row row-responsive">
<div class="col">
<div class="row row-responsive item item-divider">
<div class="col " align="center">
Last Name
</div>
<div class="col " align="center">
First Name
</div>
<div class="col " align="center">
Middle Name
</div>
<div class="col " align="center">
Address
</div>
<div class="col " align="center">
Age
</div>
<div class="col " align="center">
City
</div>
<div class="col " align="center">
State
</div>
</div>
<div class="row row-responsive item list card cardBase" ng-repeat="item in myList">
<div class = "row row-responsive">
<div class="col item-Overflow" align="center">
{{item.LName}}
</div>
<div class="col item-Overflow" align="center">
{{item.FName}}
</div>
<div class="col item-Overflow" align="center">
{{item.MName}}
</div>
<div class="col item-Overflow" align="center">
{{item.Address}}
</div>
</div>
<div class = "row row-responsive">
<div class="col item-Overflow" align="center">
{{item.Age}}
</div>
<div class="col item-Overflow" align="center">
{{item.City}}
</div>
<div class="col item-Overflow" align="center">
{{item.State}}
</div>
</div>
</div>
</div>
Where cardBase class is
.cardBase {
margin: 15px 0;
padding: 16px;
width: 100%;
height: 150px;
resize: none;
}
After doing this still data is shown in one single row. Please help me to show data in following format
As simple as this:
<ion-content>
<div class="card">
<div class="row">
<div class="col">John</div>
<div class="col">Dev</div>
<div class="col">Peter</div>
<div class="col">Washington, DC</div>
</div>
<div class="row">
<div class="col">23 Years</div>
<div class="col">Tucson</div>
<div class="col">USA</div>
</div>
</div>
</ion-content>
Check ionic grids for more.

Error while assigning id to accordion in laravel

I have added a code of accordion in my project. Till yesterday it was working fine today accordion is not working because there is space between id as shown in screen-capture from my project.
.
My code to show the accordion is:
<div class="row">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
#foreach($data as $from)
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading{{$from->id}}">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{$from->id}}" aria-expanded="true" aria-controls="collapse{{$from->id}}">
{{$from->from}}
</a>
</h4>
</div>
<div id="collapse{{$from->id}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading{{$from->id}}">
<div class="panel-body">
{{$from->body}}
</div>
</div>
</div>
#endforeach
</div>
</div>
Is there any changes i can make, to get rid of this error?
EDIT:
Controller that passes all variable.
public function show(){
$data = Email::latest()->get();
return view('emails.display',compact('data'));
}

How to make a grid same as a bootstrap in ionic?

I make a grid on ionic framework but its not work same as a bootstrap grid like as a responsive. So I want to same grid as a bootstrap.
<div class="row">
<div class="col col-33" ng-click="goProfile()">
<div class="box"></div>
</div>
</div>
<div class="col col-33" ng-click="gotoExtProfile()">
<div class="box"></div>
<div class="box-title">Extended Profile</div>
</div>
<div class="col col-33" ng-click="gotoMspAgreements()">
<div class="box"></div>
</div>
</div>
</div>
Here you can see how Ionic grid works
By default every col added inside a row will automatically receive an
equal amount of the available area.......
..... each of the five columns in this example will each evenly take up 20% of the available width (thank you flexbox).
<div class="row">
<div class="col">.col</div>
<div class="col">.col</div>
<div class="col">.col</div>
<div class="col">.col</div>
<div class="col">.col</div>
</div>
http://ionicframework.com/docs/components/#grid-even

bootstrap contact us form not working in smaller screen modes (using pull right)

I have a basic Bootstrap3 layout that looks like this:
<div class="container">
<div class="row">
<div class="col-md-4">
<h2>Section 1</h2>
</div>
<div class="col-md-4">
<h2>Section 2</h2>
</div>
<div class="col-md-4 pull-right">
<h2>Section 3</h2>
</div>
<div class="col-md-4">
<h2>Section 4</h2>
</div>
<div class="col-md-4">
<h2>Section 5</h2>
</div>
</div>
</div>
Section 3 has a basic Contact Us form, which works fine in full screen mode... But once reduced to a smaller size the user can not enter data.
When "pull-right" is removed the form funtions correctly in all size modes but then my vertical alignments with Section 4 and Section 5 are pushed down and out of line...
I need the form to work in all screen size modes and for the verticle alignment to be consistent - any help is appreciated - thanks!
From your question it is really difficult to understand what you are trying to achieve (I mean the layout) but as I see you use .pull-right class with .col-md-X and as far as I know it is a wrong approach because all .col-md-X classes have 'float: left; width: x%;' styles. Applying 'float: right' brakes your grid.
Instead you should have a look at these classes .col-md-push-X and .col-md-pull-X More info you can find in the official docs http://getbootstrap.com/css/#grid-column-ordering
UPD try this http://plnkr.co/edit/ujbqGvGwCnht9CGmKQ1r?p=preview resize plunker result window to see the result
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<h2>Section 1</h2>
</div>
<div class="col-sm-6 col-md-4 col-md-push-4">
<h2>Section 3</h2>
</div>
<div class="col-sm-6 col-md-4 col-md-pull-4">
<h2>Section 2</h2>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-4">
<h2>Section 4</h2>
</div>
<div class="col-sm-12 col-md-4">
<h2>Section 5</h2>
</div>
</div>
</div>