- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
您好,我遇到了一个与任何事情都无关的问题。
我展示了一些我的代码,希望它能有用。
请注意,当我开始创建响应式表单时,问题就出现了。
首先,这是我的 package.json:
{
"name": "name",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^6.0.3",
"@angular/common": "^6.0.3",
"@angular/compiler": "^6.0.3",
"@angular/core": "^6.0.3",
"@angular/forms": "^6.1.2",
"@angular/http": "^6.0.3",
"@angular/platform-browser": "^6.0.3",
"@angular/platform-browser-dynamic": "^6.0.3",
"@angular/router": "^6.0.3",
"@ng-bootstrap/ng-bootstrap": "^2.2.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.3",
"@angular-devkit/build-angular": "~0.6.8",
"typescript": "~2.7.2",
"@angular/cli": "~6.0.8",
"@angular/language-service": "^6.0.3",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}
这是我的 App 模块:
import {BrowserModule} from '@angular/platform-browser';
import {ModuleWithProviders, NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {SideBarComponent} from './components/side-bar/side-bar.component';
import {HttpRequestProcessComponent} from './components/http-request-process/http-request-process.component';
import {ProcessFormComponent} from './components/form/process-form/process-form.component';
import {HttpResponseComponent} from './components/http-response/http-response.component';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpClientModule} from '@angular/common/http';
import {RouterModule, Routes} from '@angular/router';
import {RuleFormComponent} from './components/form/rule-form/rule-form.component';
import {ProcessComponent} from './components/process/process.component';
import {TestCasesComponent} from './components/test-cases/test-cases.component';
import {FilterPipe, SortByPipe} from './pipes/filter.pipe';
import {SalableProductFormComponent} from './components/form/salable-product-form/salable-product-form.component';
import {CheckOrderFormComponent} from './components/form/check-order-form/check-order-form.component';
import {ModalComponent} from './components/modal/modal.component';
import {HttpProcessiComponent} from "./components/http-textarea/http-processi/http-processi.component";
import {HttpRegoleComponent} from "./components/http-textarea/http-regole/http-regole.component";
import {HttpProdottiVendibiliComponent} from "./components/http-textarea/http-prodotti-vendibili/http-prodotti-vendibili.component";
const appRoutes: Routes = [
{
path: '',
redirectTo: 'processi',
pathMatch: 'full'
},
{
path: 'processi',
component: ProcessComponent,
children: [
{
path: '',
component: ProcessFormComponent,
outlet: 'form'
}
]
},
{
path: 'regole',
component: ProcessComponent,
children: [
{
path: '',
component: RuleFormComponent,
outlet: 'form'
}
]
},
{
path: 'verifica-ordini',
component: ProcessComponent,
children: [
{
path: '',
component: CheckOrderFormComponent,
outlet: 'form'
}
]
},
{
path: 'prodotti-vendibili',
component: ProcessComponent,
children: [
{
path: '',
component: SalableProductFormComponent,
outlet: 'form'
}
]
}
];
const alternativeRoute = [
{
path: '',
redirectTo: 'processi',
pathMatch: 'full'
},
{
path: 'processi',
component: ProcessFormComponent
},
{
path: 'regole',
component: RuleFormComponent
},
{
path: 'verifica-ordini',
component: CheckOrderFormComponent,
},
{
path: 'prodotti-vendibili',
component: SalableProductFormComponent,
}
];
export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
@NgModule({
declarations: [
AppComponent,
SideBarComponent,
HttpRequestProcessComponent,
ProcessFormComponent,
HttpResponseComponent,
RuleFormComponent,
ProcessComponent,
TestCasesComponent,
FilterPipe,
SortByPipe,
SalableProductFormComponent,
CheckOrderFormComponent,
// ProductFormElementComponent,
ModalComponent,
HttpProcessiComponent,
HttpRegoleComponent,
HttpProdottiVendibiliComponent
],
imports: [
BrowserModule,
HttpClientModule,
RouterModule.forRoot(appRoutes,
{enableTracing: false}),
FormsModule,
ReactiveFormsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
准确的错误是:
ERROR in node_modules/@angular/forms/src/form_providers.d.ts(22,9): error TS2315: Type 'ModuleWithProviders' is not generic.
它似乎与我的代码没有直接关系,而是与 Angular 更深层次的配置有关。
在我的任何组件中显示任何错误。
请指教。
编辑我这样修改了路由配置:
const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes, enableTracing: false});
并且我在imports 中添加了路由。问题仍然存在。
最佳答案
表单模块版本与核心不匹配,
"dependencies": {
...
"@angular/core": "^6.0.3",
"@angular/forms": "^6.1.2",
要更正它,请使用 yarn add @angular/forms@6.0.3
或 npm install @angular/forms@6.0.3
重新安装表单(以安装程序为准)你开始了)。
之后可能还有其他依赖项需要调整,安装程序应该会告诉您。
如果您在 github 上区分 form_providers.ts 的 6.0.3 和 6.1.2 源,这是导致错误的更改:
6.0.3
import {ModuleWithProviders, NgModule} from '@angular/core';
...
export class ReactiveFormsModule {
static withConfig(opts: {
/** @deprecated as of v6 */ warnOnNgModelWithFormControl: 'never' | 'once' | 'always'
}): ModuleWithProviders {
6.1.2
import {ModuleWithProviders, NgModule} from '@angular/core';
...
export class ReactiveFormsModule {
static withConfig(opts: {
/** @deprecated as of v6 */ warnOnNgModelWithFormControl: 'never' | 'once' | 'always'
}): ModuleWithProviders<ReactiveFormsModule> {
关于 Angular 6 : error TS2315: Type 'ModuleWithProviders' is not generic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51763710/
我是 Angular 2 的新手,我需要路由部分的帮助。我正在使用 http://jasonwatmore.com/post/2016/09/29/angular-2-user-registratio
我正在通过 Angular 2 开展一个 MEAN 项目,并正在为我的各个页面设置路由。我见过很多使用 ModuleWithProviders 进行路由的示例,而不是使用 NgModule ( htt
嗨,我对 Angular 不是很有经验,也找不到解决方案 - 我正在开发一个 Ionic Cordova 项目,我想更新 Android API 级别。 之后,我无法使用该命令构建我的代码ionic
您好,我遇到了一个与任何事情都无关的问题。 我展示了一些我的代码,希望它能有用。 请注意,当我开始创建响应式表单时,问题就出现了。 首先,这是我的 package.json: { "name":
我已升级到 Angular 10,但出现以下错误: ERROR in node_modules/angularx-flatpickr/flatpickr.module.d.ts:6:64 - er
从 Angular 版本 8 升级到 10 后。 运行 - ng serve 命令给我错误 - node_modules/ngx-tree-select/src/module.d.ts:11:56 中
安装后angular-autofocus-fix导入自动对焦模块 当我运行 Angular 项目时,它显示以下错误: ERROR in node_modules/angular-autofocus-f
我正在关注 Angular js 官方的 angular 2.0 教程 site并卡在路由练习的末尾。该代码上次有效,但前几天我再次在 node.js cmd 中点击“npm start”时,“err
我正在关注 angular 2 routes guide import { Routes, RouterModule } from '@angular/router'; import { FooCom
我正在生成 https://editor.swagger.io/ Codegen 代理。 它在 Angular 10 中给出了以下错误。如何修复? Generic type 'ModuleWithPr
我正在尝试使用 Angular 创建一个 webapp,但是在编译时我收到了这个我无法解决的错误: ERROR in src/app/app.module.ts(22,5): error TS2322
我是一名优秀的程序员,十分优秀!