SoFunction
Updated on 2025-04-13

Implementation method of adding background images to labels in angular4 module

1. Phenomenon

A full-screen "revolving *" requires a background image to be added for each item, and a dynamic in-line style is required to be added in the loop label.

2. Solve

1. First there is an array of pictures, such as:

export class AppComponent {
 array = ["url(/assets/images/)","url(/assets/images/)"];
}

2. Add data to the module, such as:

<div nz-carousel-content *ngFor="let item of array" [ngStyle]="{'background-image': item }"></div>

3. Summary

We need to continue thinking, how should we operate if the array does not contain url and is just a simple image path?

The above method of adding background images to labels in the angular4 module is all the content I share with you. I hope you can give you a reference and I hope you can support me more.