在 bootstrap() 中使用 [disableDeprecatedForms(), provideForms()] 时 Angular2 表单编译错误
Angular2 forms compile error when using [disableDeprecatedForms(), provideForms()] in bootstrap()
我正在尝试按照快速入门指南 (https://angular.io/docs/ts/latest/guide/forms.html) 中的示例使用 AngularJS 2 构建普通表单。
当我按照 bootstrap() 函数中的建议禁用旧表单模块并启用新表单模块时,出现编译错误。
我对 AngularJs 很陌生。任何帮助表示赞赏。详情如下:
将“[disableDeprecatedForms(), provideForms()]”添加到 bootstrap 函数后,它会抛出编译错误。
下面是我在 main.ts 文件中的代码。
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent } from './app.component';
bootstrap(AppComponent,[ appRouterProviders ], [
disableDeprecatedForms(),
provideForms()
] );
/*
bootstrap(AppComponent,[ appRouterProviders ] );
*/
当我在 main.ts.
中有上述代码时,如果 "npm start" 正在转译,我会得到以下编译错误
如果我使用注释中显示的 bootstrap() 调用,它编译时没有错误,但会抛出警告“*看起来您正在使用旧的表单模块....”
[0] app/main.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
[0] 9:24:40 PM - Compilation complete. Watching for file changes.
如果我使用 main.ts 中的这段代码启动 "npm start",npm 将拒绝启动并抛出 ERR!。以下是 npm-debug.log 的摘录:
11 silly lifecycle angular2-quickstart@1.0.0~start: Args: [ '-c', 'tsc && concurrently "npm run tsc:w" "npm run lite" ' ]
12 silly lifecycle angular2-quickstart@1.0.0~start: Returned: code: 2 signal: null
13 info lifecycle angular2-quickstart@1.0.0~start: Failed to exec start script
14 verbose stack Error: angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (/home/justin/.nvm/versions/node/v6.3.1/lib/node_modules/npm/lib/utils/lifecycle.js:242:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/home/justin/.nvm/versions/node/v6.3.1/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:852:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid angular2-quickstart@1.0.0
16 verbose cwd /commonarea/vboxshared/www/backend/yii2/basic/web/kitchen
17 error Linux 3.19.0-15-generic
18 error argv "/home/justin/.nvm/versions/node/v6.3.1/bin/node" "/home/justin/.nvm/versions/node/v6.3.1/bin/npm" "start"
19 error node v6.3.1
20 error npm v3.10.3
21 error code ELIFECYCLE
22 error angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
22 error Exit status 2
23 error Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the angular2-quickstart package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error tsc && concurrently "npm run tsc:w" "npm run lite"
23 error You can get information on how to open an issue for this project with:
23 error npm bugs angular2-quickstart
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls angular2-quickstart
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
像这样删除括号[]
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent } from './app.component';
bootstrap(AppComponent, [
appRouterProviders,
disableDeprecatedForms(),
provideForms()
]);
我正在尝试按照快速入门指南 (https://angular.io/docs/ts/latest/guide/forms.html) 中的示例使用 AngularJS 2 构建普通表单。
当我按照 bootstrap() 函数中的建议禁用旧表单模块并启用新表单模块时,出现编译错误。
我对 AngularJs 很陌生。任何帮助表示赞赏。详情如下:
将“[disableDeprecatedForms(), provideForms()]”添加到 bootstrap 函数后,它会抛出编译错误。
下面是我在 main.ts 文件中的代码。
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent } from './app.component';
bootstrap(AppComponent,[ appRouterProviders ], [
disableDeprecatedForms(),
provideForms()
] );
/*
bootstrap(AppComponent,[ appRouterProviders ] );
*/
当我在 main.ts.
中有上述代码时,如果 "npm start" 正在转译,我会得到以下编译错误如果我使用注释中显示的 bootstrap() 调用,它编译时没有错误,但会抛出警告“*看起来您正在使用旧的表单模块....”
[0] app/main.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
[0] 9:24:40 PM - Compilation complete. Watching for file changes.
如果我使用 main.ts 中的这段代码启动 "npm start",npm 将拒绝启动并抛出 ERR!。以下是 npm-debug.log 的摘录:
11 silly lifecycle angular2-quickstart@1.0.0~start: Args: [ '-c', 'tsc && concurrently "npm run tsc:w" "npm run lite" ' ]
12 silly lifecycle angular2-quickstart@1.0.0~start: Returned: code: 2 signal: null
13 info lifecycle angular2-quickstart@1.0.0~start: Failed to exec start script
14 verbose stack Error: angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (/home/justin/.nvm/versions/node/v6.3.1/lib/node_modules/npm/lib/utils/lifecycle.js:242:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/home/justin/.nvm/versions/node/v6.3.1/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:852:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid angular2-quickstart@1.0.0
16 verbose cwd /commonarea/vboxshared/www/backend/yii2/basic/web/kitchen
17 error Linux 3.19.0-15-generic
18 error argv "/home/justin/.nvm/versions/node/v6.3.1/bin/node" "/home/justin/.nvm/versions/node/v6.3.1/bin/npm" "start"
19 error node v6.3.1
20 error npm v3.10.3
21 error code ELIFECYCLE
22 error angular2-quickstart@1.0.0 start: `tsc && concurrently "npm run tsc:w" "npm run lite" `
22 error Exit status 2
23 error Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "npm run tsc:w" "npm run lite" '.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the angular2-quickstart package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error tsc && concurrently "npm run tsc:w" "npm run lite"
23 error You can get information on how to open an issue for this project with:
23 error npm bugs angular2-quickstart
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls angular2-quickstart
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
像这样删除括号[]
import { bootstrap } from '@angular/platform-browser-dynamic';
import { disableDeprecatedForms, provideForms } from '@angular/forms';
import { AppComponent } from './app.component';
bootstrap(AppComponent, [
appRouterProviders,
disableDeprecatedForms(),
provideForms()
]);