You can use ngStyle
to set background for a div
<div [ngStyle]="{background-image: 'url(./images/' + trls.img + ')'}"></div>
or you can also use built in background style:
<div [style.background-image]="'url(/images/' + trls.img + ')'"></div>
More Related Contents:
- How do I include a JavaScript script file in Angular and call a function from that script?
- How to add conditional attribute in Angular 2?
- What’s the best way to inject one service into another in angular 2 (Beta)?
- Angular 2 Sibling Component Communication
- JS : Convert Array of Strings to Array of Objects
- Angular2 : render a component without its wrapping tag
- How to force Angular2 to POST using x-www-form-urlencoded
- Angular 4 Interceptor retry requests after token refresh
- How can I close a dropdown on click outside?
- Angular ReactiveForms: Producing an array of checkbox values?
- Print Html template in Angular 2 (ng-print in Angular 2)
- Angular 4 pass data between 2 not related components
- angular2: including thirdparty js scripts in component [duplicate]
- Angular2 5 minute install bug – require is not defined
- Angular 2, set default value to select option
- Separate Angular2 TypeScript files and JavaScript files into different folders, maybe ‘dist‘
- Call a function on click event in Angular 2
- Angular2 too many file requests on load
- ‘Access-Control-Allow-Credentials’ header in the response is ” which must be ‘true’
- How to add bootstrap in angular 6 project? [duplicate]
- Generate dynamic css based on variables angular
- What are differences between SystemJS and Webpack?
- Angular 8 – Lazy loading modules : Error TS1323: Dynamic import is only supported when ‘–module’ flag is ‘commonjs’ or ‘esNext’
- Angular2 dynamic change CSS property
- Angular 2 runOutsideAngular still change the UI
- Get Image or byte data with http
- Plain Javascript as Angular 2 service
- How to check empty object in angular 2 template using *ngIf
- How can I apply a quantity limit to *ngFor? [duplicate]
- Custom Validator on reactive form for password and confirm password matching getting undefined parameters into Angular 4