我知道这里有几个回答了相同错误的问题,但都是关于从Angular 4迁移到已删除此属性的5。
我正在尝试使用webpack构建Angular 2.4.5项目。经过一些修改和npms后,它的构建没有错误,但是当我尝试运行时,在浏览器控制台中出现以下错误:
模板解析错误:由于以下原因,无法绑定到“ ngTemplateOutletContext” 它不是“ ng-container”的已知属性。
我不使用任何ngTemplateOutletContext
属性,所以我不知道它来自哪里。我想我已经错误地更新了一些软件包,而另一些则保持旧状态,因此更新的软件包会引发错误。该项目大约在2年前使用dotnet核心aspnetcore spa角度模板构建。
如何检测此错误的根源?什么会导致有角度的2.4.5项目出现此错误?
package.json:
"dependencies": {
"@angular/common": "^2.4.5",
"@angular/compiler": "^2.4.5",
"@angular/core": "^2.4.5",
"@angular/forms": "^2.4.5",
"@angular/http": "^2.4.5",
"@angular/platform-browser": "^2.4.5",
"@angular/platform-browser-dynamic": "^2.4.5",
"@angular/platform-server": "^2.4.5",
"@angular/router": "^3.4.5",
"@types/node": "^6.0.42",
"angular2-modal": "^2.0.3",
"angular2-platform-node": "~2.0.11",
"angular2-template-loader": "^0.6.2",
"aspnet-prerendering": "^2.0.0",
"aspnet-webpack": "^1.0.17",
"awesome-typescript-loader": "^3.0.0",
"bootstrap": "^3.3.7",
"crypto": "^1.0.1",
"css": "^2.2.1",
"css-loader": "^0.25.0",
"es6-promise": "^4.2.5",
"es6-shim": "^0.35.1",
"event-source-polyfill": "^0.0.7",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^2.0.0-rc",
"file-loader": "^0.9.0",
"html-loader": "^0.4.4",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.4",
"json-loader": "^0.5.4",
"ng-select": "^1.0.0-beta.5",
"preboot": "^4.5.2",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^5.4.0",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5",
"typescript": "^2.3.4",
"url-loader": "^0.5.7",
"webpack": "^2.2.0",
"webpack-hot-middleware": "^2.12.2",
"webpack-merge": "^0.14.1",
"zone.js": "^0.7.8"
},
"devDependencies": {
"@types/chai": "^3.4.34",
"@types/core-js": "^2.5.0",
"@types/jasmine": "^2.5.37",
"@types/jquery": "^2.0.41",
"chai": "^3.5.0",
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-webpack": "^1.8.0"
}
答案 0 :(得分:1)
如何检测到此错误的根源?
您必须删除所有内容并缓慢地逐段添加,直到您碰到导致错误的事物。
将您的AppModule
减至最少,并更新您的 bootstrap 组件,使其不执行任何操作。注释掉模板中的所有HTML,并注释掉组件的所有逻辑。
您希望您的AppModule
导入不重要。只是基本的浏览器模块和通用模块。
慢慢地,开始添加回引导组件的各个部分。尝试将 router 留给最后一个模块和任何第三方模块。
如果在添加 router 或 module 时再次命中问题。尝试注释掉所有路由配置,直到再次使其可运行为止。
继续重复此过程,直到缩小范围为止。当您以最少的依赖性复制它时,您会发现它。