如何使用NgSwitch构建动态表单?

时间:2016-03-05 09:29:39

标签: angular angular2-template angular2-directives angular2-forms

我正在尝试从我的json文件

构建动态表单(textarea元素)
  {  
  "name": "description",  
  "title": "Description",  
  "type": { 
    "view": "textarea"
    }  
} 

我使用ngSwitch作为元素类型

<div *ngFor="#form of form_fields">
        {{form.type.view}}
 <span [ngSwitch]="form.type.view">  
   <span *ngSwitchWhen="textarea">    
        <md-input-container>         
      <textarea md-input [(ngModel)]="form.name" columns="1"></textarea>
        </md-input-container>
  </span>  
 </span>
 </div>

但我收到了错误

EXCEPTION: No <input> or <textarea> found inside of <md-input-container>

Plunker - 表格 这有什么问题?

enter image description here

P.S。 <md-input-container>生成错误

0 个答案:

没有答案