私は別のクラス(DetailComponent)から派生したクラス(userComponent)を持っています。私が明示的に定義したUserComponentにレンダリングされないDetailコンポーネントのテンプレート。以下のクラスとテンプレート。カッター埋め込みタイプスクリプト
ArtistlistComponent;
import { Component} from '@angular/core';
import { Auth } from '../services/auth.service'
import { SpotfyService } from '../services/spotify.service'
import { Observable } from 'rxjs/Rx';
import { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms';
@Component({
selector: 'app-users',
templateUrl: '../templates/user.component.html'
})
export class ArtistComponent {
detailedArtist:any;
artists: any;
spotfyService: SpotfyService;
showArtistDetails=false;
constructor(private auth: Auth, spotfyService: SpotfyService) {
this.spotfyService = spotfyService;
}
selectArtist(artistlink){
debugger
this.detailedArtist=artistlink;
}
}
artistlist.component.html:
<div class="row">
<form class="form-horizontal" >
<input id="searchby" class="from-control" >
</form>
</div>
<a (click)="selectArtist(artist.Id)">{{artist.name}}</a>
<artist-detail *ngIf="detailedArtist" artist="detailedArtist"></artist-detail>
detail.component.ts
import { Component } from '@angular/core';
import { Auth } from '../services/auth.service'
import { SpotfyService } from '../services/spotify.service'
import { Observable } from 'rxjs/Rx';
import { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms';
@Component({
selector: 'artist-details',
templateUrl: '../templates/detail.component.html'
})
export class DetailComponent {
selectedartist: any;
spotfyService: SpotfyService;
artistDetails;
constructor(spotfyService: SpotfyService) {
this.spotfyService = spotfyService;
}
@Input()
set artist(a:any) {
// load the details of the given artist
// a='detailedArtist' getting name of property not value ?
this.selectedartist = a;
this.isLoading=true;
this.showArtistDetails=false;
var info = this.spotfyService.getDetails(a);
info.subscribe(data=>{
this.artistDetails = data;
this.showArtistDetails=true;
this.isLoading=false;
});
}
}
detail.component.html。
<div class="row" *ngIf="isLoading">
Retrieveing artist info....
</div>
<div class="row" *ngIf="showArtistDetails">
<div class="col-md-12">
<img class="img-circle" style="width:100%" src="{{artistDetails.images[0]?.url}}">
</div>
</div>
user.component.htmlでボタンはあなたが相続を悪用している
を私は角2としてそれにタグを付けることをお勧めタイスクリプトの質問。 –
@alekkalalczyk done。 – TyForHelpDude
わかりません。 showDetails()は何をしますか?テンプレートdetail.component.htmlがユーザーコンポーネントのテンプレートに表示されるのはなぜですか?そして、なぜユーザーは詳細から継承していますか? –