Cannot bind to 'ngOutletContext', since this is not a known property of 'ng-template'

Below worked fine in Angular 4

<ng-container *ngFor="let user of list_users">
  <div *ngIf="currentUser.username !== user.username">
    <div class="card">
      bla bla
    </div>
  </div>
</ng-container>

Angular 5 whines about this error:

Can't bind to 'ngOutletContext' since it isn't a known property of 'ng-template'.
1. If 'ngOutletContext' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports' of this component.
2. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
        <!-- CUSTOM TEMPLATE -->
        <ng-template
            [ERROR ->][ngOutletContext]="{ item: model, index: index }"
            [ngTemplateOutlet]="template">
        "): ng:///TagInputModule/TagComponent.html@12:12
Property binding ngOutletContext not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("div *ngSwitchCase="true" [attr.contenteditable]="editing">
        <!-- CUSTOM TEMPLATE -->
        [ERROR ->]<ng-template
            [ngOutletContext]="{ item: model, index: index }"
            [ngTemplateOut"): ng:///TagInputModule/TagComponent.html@11:8
    at syntaxError (compiler.js:466)
    at TemplateParser.parse (compiler.js:24314)
    at JitCompiler._parseTemplate (compiler.js:33701)
    at JitCompiler._compileTemplate (compiler.js:33676)
    at eval (compiler.js:33578)
    at Set.forEach (<anonymous>)
    at JitCompiler._compileComponents (compiler.js:33578)
    at eval (compiler.js:33448)
    at Object.then (compiler.js:455)
    at JitCompiler._compileModuleAndComponents (compiler.js:33447)

Looking through the update steps: https://angular-update-guide.firebaseapp.com/ , it looks like I have nothing to do with the thing ng-template.

Also, this is the only place in my code that I use <ng-template></ng-template>

How to do it?

+6
source share
1 answer

ngOutletContexthas been removed since it was deprecated since v4. Use ngTemplateOutletContextinstead ngOutletContextin angular 5

Check this out: https://github.com/angular/angular/blob/master/CHANGELOG.md#500-beta5-2017-08-29

, : ngTemplateOutlet

+12

All Articles