如何将角度绑定@input与html元素值绑定

时间:2020-03-31 09:13:56

标签: angular

我对angular不熟悉,我想将for循环中绑定的属性值绑定到输入值

例如: 我想将名称绑定到下一个组件输入值: public class WebConfig implements WebMvcConfigurer { @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer.addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class)); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("static").addResourceLocations("classpath:/META-INF/resources/static"); } }

<input name="Name" readonly [(ngModel)]="item.name" class="form-control" id="txtName">

1 个答案:

答案 0 :(得分:2)

<other-component [userName] = "itme.name" ></other-component>

如果在for循环中使用

other-component.ts必须具有

@Input() userName:any;
相关问题