angular2
angular2 copied to clipboard
Update app.html
artist-details bothers whilst query. It looks better to hide it when there is a query expression.
or using hidden directives
<artist-details [hidden]="query" *ngIf="currentArtist" [artist]="currentArtist">
or for auto reset search and hide artist-details if null :
//app.component.ts
export class AppComponent {
.....
public edited : boolean = false;
showArtist(item) : void{
this.currentArtist = item;
this.edited=false;
}
resetSearch(item) : void{
if(item != null){
this.edited = true;
}else{
this.edited = false;
}
}
<!-- app.html -->
<input [(ngModel)]="query"
(click)="resetSearch(query)"
placeholder="type in search term">
</div>
...
<artist-details [hidden]="query"
*ngIf="currentArtist && edited==false"
[artist]="currentArtist">
</artist-details>