【发布时间】:2018-08-11 05:01:34
【问题描述】:
我的 StudentService.ts 中有一个 JSON 变量,我想从这些 JSON 中填充我的选择选项。
我的服务:
careers : {};
constructor(private http: HttpClient) {
this.selectedStudent = new Student();
this.careers = [
{"id":"itic", "name":"Sistemas"},
{"id":"itic", "name":"Sistemas"},
{"id":"itic", "name":"Sistemas"},
];
}
我的模板.html
<p>{{ studentService.careers | json }}</p>
<div class="input-field col s12">
<select>
<option ng-repeat="career in studentService.careers">{{career.name}}</option>
</select>
<label>Materialize Select</label>
</div>
template.html 中的第一行有效,并显示了我的 JSON,但我无法在我的选择中复制它。
【问题讨论】:
-
你使用的是 AngularJS 还是 Angular 2/4/5/6?
-
我正在使用 Angular 6。谢谢