问题描述
限时送ChatGPT账号..zone.js@0.6.25?main=browser:355 未处理的 Promise 拒绝:模板解析错误:'ng-template' 不是已知元素:1. 如果 'ng-template' 是一个 Angular 组件,那么验证它是否是这个模块的一部分.2. 如果'ng-template' 是一个Web 组件,则将CUSTOM_ELEMENTS_SCHEMA"添加到该组件的'@NgModule.schemas' 以抑制此消息.("[ERROR ->] ; 任务:Promise.then ; 值:错误:模板解析错误:'ng-template' 不是已知元素:
zone.js@0.6.25?main=browser:355 Unhandled Promise rejection: Template parse errors: 'ng-template' is not a known element: 1. If 'ng-template' is an Angular component, then verify that it is part of this module. 2. If 'ng-template' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->] ; Task: Promise.then ; Value: Error: Template parse errors: 'ng-template' is not a known element:
我已经在我的 App.module.ts 中应用了这个修复:
I have applied this FIX in my App.module.ts:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA ,NO_ERRORS_SCHEMA} from '@angular/core';
@NgModule({
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
JsonpModule,
CKEditorModule,
Ng2DatetimePickerModule,
Ng2DragDropModule,
DragulaModule,
ModalModule.forRoot(),
MaterialModule.forRoot(),
BootstrapModalModule,
RouterModule.forRoot(appRoutes, {useHash: true})
],
declarations: [something
],
providers: [],
bootstrap: [AppComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA ]
})
PACKAGES.JSON
PACKAGES.JSON
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/router": "3.2.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"jquery": "~3.1.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@angular/compiler-cli": "2.2.1",
"@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
"angular-cli": "1.0.0-beta.21",
"codelyzer": "~1.0.0-beta.3",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.9",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "~2.0.3",
"webdriver-manager": "10.2.5"
}
即使在此之后它也不起作用.
Even after this it is not working.
推荐答案
更新angular-cli:https://github/angular/angular-cli/wiki/stories-1.0-update更新打字稿和可选的@angular
包.你的包相当落后,最重要的是 angular-cli
,所以要做好准备.我的核心包:
Update angular-cli: https://github/angular/angular-cli/wiki/stories-1.0-update
Update typescript and optionally your @angular
packages. Your packages are pretty behind, most importantly angular-cli
, so be prepared.
My core packages:
dependecies: {
"@angular/animations": "^4.0.2",
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/compiler-cli": "^2.4.10",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/material": "^2.0.0-beta.3",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/platform-server": "^4.0.0",
"@angular/router": "^3.3.1"
}
devDependencies: {
"@angular/cli": "^1.0.0",
"typescript": "^2.2.2"
}
npm install @angular/material &&npm installhammerjs ---save
在angular-cli.json
中添加/node_modules/hammerjs/hammer.js
将单个模块导入您的 app.module
,并相应地导出,然后只需将标签添加到 html
import individual modules into your app.module
, and export accordingly then simply add tags to html
这篇关于如果 'ng-template' 是 Web 组件,则添加“CUSTOM_ELEMENTS_SCHEMA";到此组件的 以抑制此消息.("[错误 ->]<ng-template>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论