相关疑难解决方法(0)

Angular 5:"没有ControlContainer的提供者"

我有一个使用Angular 5的小型Web应用程序,突然间我在浏览器控制台中收到这个奇怪的错误消息:

ncaught Error: Template parse errors:
No provider for ControlContainer ("
</p>
<form class="container" (ngSubmit)="update()">
  [ERROR ->]<app-form-group-component 
[formGroup]="additionalInformation"></app-form-group-component>
      <button "): ng:///AppModule/KickoffComponent.html@4:2
Run Code Online (Sandbox Code Playgroud)

之前没有发生这种情况,我不知道有任何改变.我不知道那条消息试图告诉我什么.

这是form-group的组件模板,似乎无论如何都是无效的:

<div *ngFor='let e of formGroup' class="form-group">
<label for="{{e.key}}">{{e.label}}</label>
<input type="{{e.type}}" name="{{e.key}}" 
[(ngModel)]="e.value" class="form-control" 
[ngClass]='{"is-valid": e.valid === true && e.required === true}'
        />
    </div>
Run Code Online (Sandbox Code Playgroud)

这是我使用form-group的模板:

<form class="container" (ngSubmit)="update()">
 <app-form-group-component [formGroup]="additionalInformation"></app-form-group-component>
  <button type="submit" class="btn btn-primary">Submit</button>
</form>
<app-notification [notification]="notification"></app-notification>
Run Code Online (Sandbox Code Playgroud)

我盯着它看了几个小时,但我找不到任何错误.

我应该提一下,我不使用Angular的FormGroup,而是使用我自己的解决方案(因为我认为他们的工程过度,并不符合我的特定需求).会不会有某种名字碰撞?当然,在app.module中,我导入了用于双向绑定的FormsModule,并拦截了表单的提交.通知组件至少在没有投诉的情况下工作.

我会非常感谢任何帮助.

编辑: 我被要求分享我的TS代码.

失败的组件:

import { Component, Input } from '@angular/core';
import { FormGroup } from '../../models/form-group';

@Component({ …
Run Code Online (Sandbox Code Playgroud)

angular angular5

29
推荐指数
4
解决办法
3万
查看次数

在 Ionic 中使用表单会抛出 Error: NodeInjector: NOT_FOUND [ControlContainer]

我创建了一个带有表单的 Ionic 应用程序。没什么特别的(代码如下)。在我添加表单并使用表单组和其他东西之前,它工作得很好。当我开始添加表单组和所有连接的东西时,我收到此错误:

\n\n
\n

core.js:6260 错误错误:未捕获(承诺中):错误:NodeInjector:\n NOT_FOUND [ControlContainer] 错误:NodeInjector: NOT_FOUND\n [ControlContainer]\n 位于 getOrCreateInjectable (core.js:5894)\n 模块处。 \xc9\xb5\xc9\xb5directiveInject (core.js:21115)\n 在 NodeInjectorFactory.NgControlStatusGroup_Factory [作为工厂] (forms.js:1073)\n 在 getNodeInjectable (core.js:6025)\n 在 instantiateAllDirectives (core. js:12953)\n 在 createDirectivesInstances (core.js:12169)\n 在 \xc9\xb5\xc9\xb5elementStart (core.js:21298)\n 在 EditPage_Template (template.html:18)\n 在executeTemplate (core) .js:12129)\ n在renderView(core.js:11899)\ n在resolvePromise(zone-evergreen.js:798)\ n在resolvePromise(zone-evergreen.js:750)\ n在zone-evergreen.js :860\n 在 ZoneDelegate.invokeTask (zone-evergreen.js:399)\n 在 Object.onInvokeTask (core.js:41640)\n 在 ZoneDelegate.invokeTask (zone-evergreen.js:398)\n 在区域。 runTask (zone-evergreen.js:167)\n 在rainMicroTaskQueue (zone-evergreen.js:569)

\n
\n\n

我尝试了在网上找到的东西:\n从文件 app.module.ts 中的 @angular/forms 导入 Forms Module 和 ReactiveFormsModule

\n\n

这对我不起作用,并且我不断收到错误。

\n\n

我在 SO 上找到并尝试过的链接,但没有成功:

\n\n

Angular Error: …

ionic-framework angular

2
推荐指数
1
解决办法
5248
查看次数

标签 统计

angular ×2

angular5 ×1

ionic-framework ×1