Failed to show image (base64) using async pipe after upgrade from RC3 to RC4
Ionic version: (check one with "x") [ ] 1.x [x ] 2.x
I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
Upgrading from RC3 to RC4. Using async pipe to resolve user id into image (in base 64 format) from either locally saved cache or fresh from server. The data (base 64) is sucessfully grabbed from within the pipe, but not get updated in the view. Working perfect in RC3 but failed in RC4. Debugger keep pointing to this line in img.js file.

Expected behavior:
Image will show after a while.
Steps to reproduce:
Related code:
The pipe:
import {Pipe, PipeTransform} from '@angular/core'
import {ImageHandlerUtilities} from '../ImageHandler'
import qlib from 'q'
@Pipe({
name:'resolveImage'
})
export class ImageResolverPipe implements PipeTransform {
constructor(public imageHandler:ImageHandlerUtilities){}
transform(value:number, type:string){
var deferred = qlib.defer()
if(value){
// user profile image
if(type === 'CXPerson'){
this.imageHandler.getProfileImageByUserId(value).then(
(res:string)=>{
// base 64 data
deferred.resolve(res)
},
(error)=>{
error.unshift({ loc: 'ImageResolverPipe:transform:ix-1 ' })
console.error(error)
}
)
}
// team profile image
else if(type === 'CXTeam'){
this.imageHandler.getTeamProfileImageByTeamId(value).then(
(res:string)=>{
// base 64 data
deferred.resolve(res)
},
(error)=>{
error.unshift({ loc: 'ImageResolverPipe:transform:ix-2 ' })
console.error(error)
}
)
}
}
else{
// default random dummy image
deferred.resolve('http://lorempixel.com/g/100/100/people/')
}
return deferred.promise
}
}
Usage example:
<ion-img [src]="user_id | resolveImage:'CXPerson' | async"></ion-img>
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Your system information:
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.4
Node Version: v6.7.0
Xcode version: Not installed
I've made a simple example based on ionic 2 tutorial demo if you want to give it a try.
https://github.com/lufias/ionic-image-sync
This time, I simply resolve a string right away from within the pipe. The string will be later attached to ion-img src attributes.
Pipe:
@Pipe({
name:'resolveImage'
})
export class ImageResolverPipe implements PipeTransform {
constructor(){}
transform(value:number){
var deferred = qlib.defer()
deferred.resolve('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCws..
But debugger still throw me error of 'Cannot read property indexOf null' which is the 'newSrc' object in img.js.

Comparing img.ts from both RC3 and RC4, i saw quite some changes. It appear to me that in RC3 there is some kind of check to see if the src truly present before proceed any futher.
I end up replacing all ion-img with html own img tag..
Hello! Sorry you are running into issues here, we will look into this!
Ok, I got it to work after change [src]="" to src="{{}}".
<ion-img src="{{(myimg | async)?.url}}" style="width: 100%; height: 160px;" cache="true"></ion-img>
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Thank you for using Ionic!