I want to hide a tablerow if the string value of the url property of my project is empty. So this is my code:
<div class="tableRow" *ngIf="(project | async)?.Url">
<div class="tableCell"><a target="_blank" href="{{ (project | async)?.Url}}">{{ this.localizationService.localized['projectUrl'] }}</a></div>
</div>
The problem is that if i use the code above the row is beeing displayed but the url value in the href is empty.
As soon as i delete the ngIf the row is shown as well but this time the url is not empty.
<div class="tableRow">
<div class="tableCell"><a target="_blank" href="{{ (project | async)?.Url}}">{{ this.localizationService.localized['projectUrl'] }}</a></div>
</div>
what am i doing wrong?
EDIT: The project is requested from our backend in the projectservice. I have an observable in the project component.
I'm terrible at explaining, im sorry...
ProjectComponent
private project: Observable<ProjectDetail>;
constructor() {
super();
// init projects stream
this.project = projectsService.projectDetail;
}
ProjectService
public getProjectDetail(id: number) {
this.http.get(this.projectDetailUrl + id)
.map(this.utilService.extractData)
.map(this.mapProjectDetails)
.subscribe(data => {
this.dataStore.projectDetail = data;
this.projectDetail$.next(this.dataStore.projectDetail);
},
err => {
this.httpErrorHandler.handleError(err);
});
}