Error StaticInjectorError[ViewContainerRef] when having *ngIf or *ngFor // Solution: `--preserve-symlinks`
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
When I am using either *ngIf or *ngFor in my template I got this error message: StaticInjectorError[ViewContainerRef]
. Any ideas why this happen?
How To Reproduce
- Create a component
footer.component.ts
- Add *ngIf in
footer.component.html
- Run
ng-packagr -p ng-package.json
andnpm publish
- Install on new Angular 5 app (
npm install
) - Run my Angular 5 App
ng serve
Here is my code:
footer.component.ts
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-footer',
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.scss']
})
export class FooterComponent implements OnInit {
@Input() isTrue: boolean;
constructor( ) { }
ngOnInit() { }
}
footer.component.html
<footer>
<h2 *ngIf="isTrue">Hello</h2>
</footer>
Expected Behaviour
Should not error
Version Information
ng-packagr: ^1.6.0
node: v7.6.0
@angular: v5.0.2
rxjs: v5.5.2
zone.js: v0.8.18
Issue Analytics
- State:
- Created 6 years ago
- Comments:25 (5 by maintainers)
Top Results From Across the Web
Angular custom library ngFor and ngIF error - Stack Overflow
In your angular.json locate build property under the architect, and in options add "preserveSymlinks": true I think this will solve your problem ...
Read more >Bountysource
Error StaticInjectorError [ViewContainerRef] when having *ngIf or *ngFor // Solution: `--preserve-symlinks`
Read more >I Am Facing The Issue In Angular 5 . *Ngfor Not Working ...
Error StaticInjectorError [ViewContainerRef] when having *ngIf or *ngFor // Solution: --preserve-symlinks #304. Closed. doenikoe opened this ...
Read more >How to use ngfor,ngif together on same element in angular
In Angular,To use ngfor and ngif together on same element place the *ngIf on a parent element ... The above code returns following...
Read more >Staticinjectorerror(appmodule angular 6), 承诺错误staticinjectorerror ...
Error StaticInjectorError [ViewContainerRef] when having *ngIf or *ngFor // Solution: `--preserve-symlinks` Add import { HttpModule } from '@angular/http'; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still facing with
StaticInjectionError
even with--preserve-symlinks
flag. Unfortunately it’s not the solution for*ngIf
and*ngFor
case.Have you tried the
--preserve-symlinks
flag?