角14增加了一个名为FormRecord的新类,它允许创建比FormGroup更动态的表单控件。Docs有一个这样的例子
FormRecord接受一个泛型参数,该参数描述它包含的控件的类型。
let numbers = new FormRecord({bill: '415-123-456'});
numbers.addControl('bob', '415-234-567');
numbers.removeControl('bill');
但是当我在代码中使用这个例子时,我得到了一个错误。
let numbers = ne
我正在尝试构建用angular7开发的web应用程序的生产版本,编译运行得很好。但当我试图导航到应用程序时,控制台中出现了一个错误:
Uncaught TypeError: ctor is not a constructor
at _createClass (main.07add232d9f568bb2d7a.js:33609)
at _createProviderInstance (main.07add232d9f568bb2d7a.js:33583)
at initNgModule (main.07add232d9f568bb2d7a.js:33514)
a
我希望能够使用组件构建一个反应性表单,但不希望将其全部设置在一个父组件中。因此,我创建了初始FormGroup并将其传递给组件,然后组件执行this.form.addControl(this.fb.group({ ... }));将它们的组添加到表单中。
示例
父组件
this.form = this.fb.group({}); // Empty
public ngAfterViewInit() {
// Throws error after trying to patchValue on the child component
this.form.get('example&
如何以角度重置表单值,例如,我希望重置createUserForm的值,但它不应该包括或重置我在addControl上添加的数据。谢谢
我尝试了this.createUserForm.reset();但是它重置了,包括我添加的添加控件,而我不想要这些控件。只有createUserForm上的字段
#代码
createUserForm = new FormGroup({
emailAddress: new FormControl(),
firstName: new FormControl(),
lastName: new FormControl(),
phon
我正在使用角7应用程序,我正在编写一个通用的动态表单创建者。我正在使用reactive和ng-template and <ng-container *ngTemplateOutlet>递归地显示表单element.The代码,可以看到。
但我面临以下错误
ERROR Error: Cannot find control with name: 'data'
at _throwError (forms.js:1775)
at setUpControl (forms.js:1683)
at FormGroupDirective.push../n
我有一个非常奇怪的问题,角2应用程序在火狐和所有的ios浏览器(火狐,safari)
当用户在我的应用程序中输入/reports路由时,我将通过ngOnInit方法调用rest来获取json数据。
这是我的ngOnInit方法中处理数据加载的部分:
ngOnInit() {
//this.service is my service to get reports
this.service.getReports(this.categoryId).subscribe(res => {
this.testReports = res;
}
}
当我得到响应后,我将我