0

In following code I want to apply animations on div [ngStyle]="{'width': object.widthValue}"
When width increase that will animated

<ion-row *ngFor="let object of barArray">
          <ion-col class="cityTxt" col-3>{{object.yLable}}</ion-col>
          <ion-col col-9>
            <div class="lksDiv">
              <b>{{object.widthValue}}</b> {{object.unit}}</div>
            <div class="greyline">
              <div class="blueline"  [ngStyle]="{'width': object.widthValue}"></div>
            </div>
            <div class="lastLks">{{object.endLabel}}</div>
          </ion-col>
        </ion-row>

So In screenshot blue bar will be show as like animations
I am new to angular5 Can anyone help me out?

enter image description here

Gitaram Kanawade
  • 341
  • 1
  • 4
  • 19

2 Answers2

2

In the ngStyle part you didn't used any units. try 'px' or '%' . if the div didn't rendered at all use non-breaking space . this should work for you.

<div class="blueline" [ngStyle]="{'width': object.widthValue+'%'}" > &nbsp;</div>
Masso
  • 56
  • 4
0

you can try in the way:

html:

<div class="greyline">
    <div class="blueline"  [ngStyle]="{'width': object.widthValue}"></div>
</div>

less:

.grayline {
  height: 8px;
  width: 100%;
  background-color: #fec701;
  border-radius: 4px;

  .blueline {
    height: 8px;
    width: 0;
    background-color: #184576;
    border-radius: 4px;
    transition: all .6s ease-in-out;
  }
}

while the css layout may not fit yours. The key word may be the transition, hope it helps.

allen wang
  • 1,087
  • 2
  • 7
  • 16