【问题标题】:Template parse errors: Can't bind to 'ngOutletContext' since it isn't a known property of 'ng-template'. 1. If 'ngOutletContext' is an Angula模板解析错误:无法绑定到“ngOutletContext”,因为它不是“ng-template”的已知属性。 1. 如果 'ngOutletContext' 是 Angula
【发布时间】:2019-05-19 15:15:42
【问题描述】:

您好,我和我的团队已将 Angular 应用程序从 4.3.2 更新到 Angular 7.1.3。迁移的所有包和 angular.json 指向相同。但在控制台中,我们收到“无法绑定到 'ngOutletContext'”。没有在应用程序中使用此属性的位置。它只出现在 Vendor.js 中。错误信息如下。

compiler.js:2427 未捕获错误:模板解析错误: 无法绑定到“ngOutletContext”,因为它不是“ng-template”的已知属性。 1. 如果 'ngOutletContext' 是 Angular 指令,则将 'CommonModule' 添加到该组件的 '@NgModule.imports' 中。 2. 要允许任何属性,请将“NO_ERRORS_SCHEMA”添加到该组件的“@NgModule.schemas”中。 (" ][ngOutletContext]="day.context"> "): ng:///NgbDatepickerModule/NgbDatepickerMonthView.html@13:58 嵌入模板上的任何指令均未使用属性绑定 ngOutletContext。确保属性名称拼写正确,并且所有指令都列在“@NgModule.declarations”中。 (" [class.hidden]="isHidden(day)"> [错误->] "): ng:///NgbDatepickerModule/NgbDatepickerMonthView.html@13:12 在 syntaxError (compiler.js:2427) 在 TemplateParser.push.../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:20311) 在 JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:25857) 在 JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:25844) 在 compiler.js:25787 在 Set.forEach() 在 JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:25787) 在 compiler.js:25697 在 Object.then (compiler.js:2418) 在 JitCompiler.push.../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:25696) 1. 如果 'ngOutletContext' 是 Angular 指令,则在该组件的 '@NgModule.imports' 中添加 'CommonModule'

当前的 Angular 设置是。

"devDependencies": {
    "@angular-devkit/build-angular": "^0.11.3",
    "@angular/cli": "^7.1.3",
    "@angular/compiler-cli": "^7.1.3",
    "@biesbjerg/ng2-translate-extract": "^0.6.0",
    "@types/core-js": "^0.9.43",
    "@types/geojson": "^1.0.6",
    "@types/highcharts": "^5.0.12",
    "@types/jasmine": "^2.5.47",
    "@types/jspdf": "^1.1.31",
    "@types/leaflet": "^0.7.31",
    "@types/lodash": "^4.14.61",
    "@types/node": "^7.0.12",
    "codelyzer": "2.1.1",
    "core-js": "^2.5.1",
    "env2json": "^1.0.0",
    "hads": "1.3.3",
    "htmlhint": "0.9.13",
    "https-proxy-agent": "^1.0.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "^3.2.0",
    "karma": "^1.5.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.0.0",
    "karma-jasmine": "^1.1.0",
    "karma-junit-reporter": "^1.2.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "lite-server": "^2.3.0",
    "phantomjs-prebuilt": "^2.1.14",
    "protractor": "~5.1.0",
    "stylelint": "7.10.1",
    "stylelint-config-standard": "16.0.0",
    "ts-node": "3.0.2",
    "tslint": "~4.5.0",
    "typescript": "3.1.6"
  }

【问题讨论】:

  • @SureshKumarAriya 如描述中所示,代码中没有 [ngOutletContext] 存在的位置。我们到处找。上述问题回答了更改 标签。在我们的应用程序中,我们在任何地方都没有标签。

标签: angular typescript angular6 angular7 angular4-forms


【解决方案1】:

用 ngTemplateOutletContext 替换 ngOutletContext。

它在角度更新指南中提到。有关完整的详细信息,请访问

https://update.angular.io/

【讨论】:

  • 我们同时使用了 angular.io/cli/update 和 update.angular.io 进行迁移。在 VS Code 中搜索没有我们可以找到“ngOutletContext”的地方
  • 读取错误 ng:///NgbDatepickerModule/NgbDatepickerMonthView.html@13:58 嵌入模板上的任何指令未使用属性绑定 ngOutletContext ......,你是使用第三方库,对于 DatePicker 我猜问题可能在那里
猜你喜欢
  • 1970-01-01
  • 2018-02-12
  • 2018-01-25
  • 1970-01-01
  • 2017-06-02
  • 1970-01-01
  • 2017-05-07
  • 2017-09-25
  • 1970-01-01
相关资源
最近更新 更多