Skip to content

Instantly share code, notes, and snippets.

@yoelnacho
Last active July 13, 2017 01:04
Show Gist options
  • Save yoelnacho/b0960e4f2403847eb56c43ac1b3e6abc to your computer and use it in GitHub Desktop.
Save yoelnacho/b0960e4f2403847eb56c43ac1b3e6abc to your computer and use it in GitHub Desktop.
Angular2 Pipe: Sin imagen
<img [src]="artist.images | sinfoto">
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'sinfoto'
})
export class SinfotoPipe implements PipeTransform {
transform(value: any[]): string {
let noimage = "assets/img/noimage.png";
if( !value ){
return noimage;
}
return ( value.length > 0 ) ? value.url : noimage;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment