My code is below and I want to change icon up and down when collapse and expand is done. But somehow it's not working.
<div class="attach-link">
<a href="javascript:void(0);" *ngIf="fileData.fileDataType.canAttach && !isFinancialEntity" (click)="openFileInput(i)">
<i class="fa fa-plus"></i> Add Attachment</a>
<input type="file" class="hide" id="fileData_{{i}}" ng2FileSelect [uploader]="fileData.uploader" (onFileSelected)="onFileSelected()"
/>
<a class="attachFileList" href="#attachFileList_{{i}}" data-toggle="collapse">
<i class="fa fa-angle-up" ></i>
Attachments [{{fileData.fileList.length}}] </a>
</div>
And added script :
$('a[data-toggle="collapse"]').click(function () {
//$(this).find('i').addClass('fa fa-angle-up').removeClass('fa fa-angle-down');
$(this).find('i .fa fa-angle-up').toggleClass('fa fa-angle-down');
});
I don't know what is the problem. Any help will be appreciated. Many Thanks.
Here is the sample code of collapse up and down in angular.
<div class="attach-link">
<a href="javascript:void(0);" (click)="openFileInput(i)">
<i class="fa fa-plus"></i> Add Attachment</a>
<input type="file" class="hide" id="fileData_{{i}}" ng2FileSelect (onFileSelected)="onFileSelected()"
/>
<br>
<a (click)="collapse=!collapse" class="attachFileList" href="#attachFileList_{{i}}" data-toggle="collapse">
<i class="fa" [ngClass]="{'fa-angle-up': collapse, 'fa-angle-down': !collapse}"></i>
Attachments {{fileData.fileList.length}}
</a>
</div>
Controller
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular 5';
collapse:boolean =true;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With