6

I am working on a sample project with a loginComponent, I need to implement OnInit in my class when i try to add the OnInit i am getting the following error

[ts] cannot find OnInit

Here is my code

export class loginComponent implements OnInit{

 ngOnInit():all{

    }
}

How to solve this issue

Thanks in advance

halfer
  • 19,824
  • 17
  • 99
  • 186
skid
  • 958
  • 4
  • 13
  • 29

2 Answers2

22
import { OnInit } from '@angular/core';
kdev
  • 705
  • 7
  • 11
6

You need to import it from "@angular/core". Also, you don't need to return anything from this method, so you can safely skip returning type.

import {OnInit} from '@angular/core';

export class loginComponent implements OnInit {
    ngOnInit() {

    }
}
Alexander Leonov
  • 4,694
  • 1
  • 17
  • 25