【发布时间】:2018-01-25 10:38:20
【问题描述】:
我需要创建一个网页,其下拉菜单的值分别为 ALL 、 Test1 和 Test 2。
现在如果用户正在选择:
All ---> localhost:8080/testcases
Test1 --> localhost:4200/testcases?module=Test1
Test2 ->localhost:4200/testcases?module=Test2
我在module.component.ts下面创建了:
import { Component, OnInit } from '@angular/core';
import { Testcase } from '../testcase';
import { DataService } from '../data.service';
@Component({
selector: 'app-module',
templateUrl: './module.component.html',
styleUrls: ['./module.component.css']
})
export class ModuleComponent implements OnInit {
testCases: Testcase[];
types= ["ALL", "Test1", "Test2"];
getTestcases() {
return this.dataService.getTestcases().then(testCases => this.testCases = testCases);
}
constructor(private dataService: DataService) {}
ngOnInit() {
}
}
对应的html文件:
<div> type:
<select>
<option *ngFor="let i of type">{{i}}</option>
</select>
</div>
在这里,getTestcases() 向我返回了所有正确的响应
localhost:4200/testcases(如果我从相应的测试用例组件调用它),但我不确定在模块组件中如何使用此下拉列表
call,自从我第一次与 Angular4 交互以来,我完全被卡住了,无法
要更进一步,需要您的建议
【问题讨论】:
标签: angular angular5 angular4-router