1
當我的詳細信息爲空時,我的模板未顯示,但當詳細信息具有值時顯示該模板。我已在此處構造並且無法找到解決方案。可以請某人幫忙我.......... 我的HTML,當值爲空時,表單不顯示
<div class = "nopadding col-sm-12">
<form class="nobottommargin" [formGroup]="form" (ngSubmit)="onSubmit(form.value)" name="template-contactform">
<div class="col-sm-12 nopadding socialaddress">
<div class="col-sm-12 formpaddingcss">
<h3 class = "headingfontcss">SOCIAL ADDRESS</h3>
</div>
<div class="col-sm-12 formpaddingcss cardbackgroundcolor">
<div class="col-sm-7 cardtopbottompadding noleftpadding">
<div class="col-sm-12 nopadding">
<label for="template-contactform-name" class="col-sm-5 nopadding">FACEBOOK <small>*</small></label>
<div class="col-sm-7 nopadding text-right">
<span class="cardtextcolor" tooltip="Log in to your facebook account and click on your profile, copy and paste url from there" [tooltipDisabled]="false" [tooltipAnimation]="true"
tooltipPlacement="top"><i class="icon-question-sign"></i> What is my address?</span>
</div>
</div>
<div class="input-group divcenter">
<span class="input-group-addon noradius inputgroupaddon"><i class="icon-facebook"></i></span>
<input type="email" tooltip="Enter Facebook url" [tooltipDisabled]="false" [(ngModel)]="details.facebook" class="form-control required email formcontrolheight" placeholder="Facebook" aria-required="true">
</div>
</div>
</form>
我的TS,
export class Social {
message: any;
http: Http;
details: IDetails[];
form: FormGroup;
constructor(fbld: FormBuilder, http: Http, private _service: GetAllList,public toastr: ToastsManager) {
this.http = http;
this._service.getList()
.subscribe(details => this.details = details);
}
HTTP調用TS,
getList(): Observable<IDetails[]> {
// console.log(this.id);
return this._http.get(this._productUrl)
.map((response: Response) => {
if(response.json().error_code ==0){
return <IDetails[]>response.json().data[0];}
});
}
}
Gunter,仍然沒有顯示我的表單,我需要在表單中填寫details = []嗎? – MMR
在控制檯中是否出現錯誤?如果細節是一個數組,那麼'details.facebook'似乎不是有效的。這將是'細節。[0] .facebook'或類似的東西。 –
我沒有收到任何錯誤 – MMR