>PROBLEM
The angular app throws the following error during attempt to open a child modal:
Error: NG0301
This error may have many types of causes.
It usually means some issue between the component and the template configuration or some subjacent library version incompatibility.
Below there are the four different solutions from different real cases that worked for me.
NOTE: the 3rd solution is the one that I most use. If you are sure that nothing changed in your code, try it. Run the "npm audit fix --force" once or more, but make sure that a node_modules backup is made before. If this folder gets corrupted, fixing it is time-consuming.
>SOLUTION #1
>before
>after
The second one was switched to solve the conflict.
>SOLUTION #2
>before
- todos.component.ts (parent-child biding):
<!-- xxmodal TODO UPDATE -->
<app-uptodo [theTodo]="todoi" [email]="email" [stoken]="stoken" [activity]="activity" [activities]="activities"
(click)="setTodoi(todo)" (updateEvent)="updateTodo($event)"></app-uptodo>
<!-- xxupdate -->
- uptodo.component.ts (child):
export class UptodoComponent implements OnInit {
modalRef: BsModalRef;
@Input()
email: string;
@Input()
stoken: string;
@Input()
activities = [];
@Input()
theTodo: any;
activity: string;
@Output()
updateEvent = new EventEmitter<string>();
>after
- uptodo.component.ts (child):
export class UptodoComponent implements OnInit {
// ...
@Input()
activity: string;
@Output()
updateEvent = new EventEmitter<string>();
>SOLUTION #3
Stop the app.
npm install
2. Apply the fix command:
npm audit fix
npm audit fix --force
>SOLUTION #4
Do:
npm update
After the update, it may appear some VSCode error messages.
Restart VSCode.
>ENV
Angular CLI: 13.2.2
Node: 16.13.1
Package Manager: npm 8.5.4
OS: win32 x64