2017-11-10 12 views
6

Poniżej pracował dobrze w Kątowymi 4nie może wiązać się z „ngOutletContext”, ponieważ nie jest znana własność „NG-szablonu”

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

Kątowymi 5 jest marudzenie o tym błędzie:

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/[email protected]: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/[email protected]: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) 

Przeglądając kroki aktualizacji: https://angular-update-guide.firebaseapp.com/, nie wydaje mi się, aby coś związanego z rzeczą ng-template.

Plus, to jedyne miejsce w moim kodu używam <ng-template></ng-template>

Jak mogę to idzie?

+2

Kwestia ta została wymieniona na [meta] (https://meta.stackoverflow.com/q/359165)./cc @ GünterZöchbauer. –

+0

Więc wziąłem swój czas na drążenie do błędu. Używałem paczki innej firmy (ngx-chips), która wciąż używała wycofanego, na co narzeka. Aktualizacja pakietu naprawiła błąd. https://github.com/Gbuomprisco/ngx-chips/issues/593 – Rexford

Odpowiedz

10

ngOutletContext has been removed as it was deprecated since v4. Use ngTemplateOutletContext instead of ngOutletContext in angular 5

Sprawdź to: https://github.com/angular/angular/blob/master/CHANGELOG.md#500-beta5-2017-08-29

i podjąć dyskusję, jeśli chcesz: Can't get ngTemplateOutlet to work

+2

: D zastąpione przez siebie? Myślę, że zapomniałeś '# outletContext' –

+0

@ GünterZöchbauer Zaktualizowałem swoją odpowiedź; Zostałem właśnie skopiowany z linku, o którym już wspominano 'NgTemplateOutlet # ngOutletContext został usunięty, ponieważ był przestarzały od wersji v4. Użyj NgTemplateOutlet # ngTemplateOutletContext zamiast': P –

Powiązane problemy