When I create a new component file in my angular project by " ng g c 'component name' ", OnInit
is not there initially in my component file.
Asked
Active
Viewed 594 times
0

Andrew Allen
- 6,512
- 5
- 30
- 73

Akhil K
- 1
3 Answers
3
It has been removed in Angular 15. You can also add it manually
@Component({
...
})
export class MyComponent extends OnInit {
ngOnInit(): void {
// your init code
}
}

Andrew Allen
- 6,512
- 5
- 30
- 73

Nirmal Kumar
- 45
- 6
1
you can add it manually by yourself
@Component({
selector: 'app-component',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent extends OnInit {
ngOnInit(): void {
}
}

Manoj Kumar
- 25
- 7