【发布时间】:2021-06-12 21:24:24
【问题描述】:
如何实现 .map 的 react with angular。
React 示例:
const options = ['Car', 'Bus', 'Truck', 'Bike', 'Motorcycle'];
const compTest = () => (
<select>
{options.map((vehicle) => <option>{vehicle}</option>)}
</select>
)
我如何使用角度组件来做到这一点?
【问题讨论】:
-
你需要使用
*ngFor来显示list。 A related post. -
<select> <option *ngFor="let item of options">{{item}}</option> </select>(angular.io/api/common/NgForOf#description) -
1. AngularJS != Angular2+。 2. 如果您是 Angular 新手,我建议您阅读他们的快速教程 here。它介绍了一些基础知识。
标签: angular typescript