View not updating when assigning null property to object in Angular using 'rxjs/observable/zip' -
i'm having problem with view not being updated once component has updated local property / variable.
in component code create 'newalbum' property , assign null. later when calling method in component called opencreateform wish assign values 'newalbum' property , wish update view using simple *ngif
this typescript code in component...
newalbum: { title: string, editableimagelist: editableimage[], description: string, fromdate: string} = null; constructor(private store: store<any>, private fileservice: fileservice) { // more stuff here isn't important } opencreateform(filelist: file[]) { const editableimageobservablelist = _.map(filelist, (file) => { return this.fileservice.imagefiletodataurl(file) .map((dataurl) => { return new editableimage(null, dataurl); }); }); zip(...editableimageobservablelist).subscribe((editableimagelist: editableimage[]) => { this.newalbum = { title: 'my new album', editableimagelist, description: null, fromdate: string(moment().year()) }; }); } and html in component template (in external file)
<div class="album__create" *ngif="newalbum"> content should shown... </div> when debugging in chrome dev tools , firing opencreateform method correct arguments this.newalbum correctly assigned correct properties , no longer null... view doesn't updated. should toggle between divs on interface *ngif="newalbum" works correctly when returning or switching tabs in view. can anyway give me idea on why update isn't being fired or force update? many thanks
if of above doesn't make sense please state , reword question... many again.
newalbum of type any object literal. rather relying on duck-typing ensure new version of object picked change detection, why not create interface it.
interface album{ title: string; editableimagelist: editableimage[]; description: string; fromdate: string } then
newalbum: album; and in subscription:
this.newalbum = <album>{ title: 'my new album', editableimagelist, description: null, fromdate: string(moment().year()) }; this may change-detection tracking property, of well-known type
Comments
Post a Comment