Last active
          August 28, 2017 14:51 
        
      - 
      
 - 
        
Save davidgjordan/65560eb0775c600bc72c7eeef062b72a to your computer and use it in GitHub Desktop.  
    Styles Background poner backgruond mediante styles
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { Component} from '@angular/core'; | |
| import { DomSanitizer} from '@angular/platform-browser' | |
| @Component({ | |
| selector: 'app-books', | |
| templateUrl: './books.component.html' | |
| }) | |
| export class BooksComponent implements OnInit { | |
| public urlImage:string; | |
| constructor(private _sanitizer:DomSanitizer) { | |
| this.urlImage = "assets/img/project-2.jpg" ; | |
| } | |
| public sanitizeImage(image: string) { | |
| return this._sanitizer.bypassSecurityTrustStyle(`url(${image})`); | |
| } | |
| } | |
| //HTML | |
| [style.background-image]="sanitizeImage(urlImage)" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment