Angular 4 is expanding and implemented

I have a Hero class that needs to extend the GoogleCharts class. I also need to implement OnInit to get some data from the parameters.

How can i do this?

+4
source share
1 answer

Similar:

export class Hero extends GoogleCharts implements OnInit {...

If GoogleCharts already implements OnInit, you must call super.ngOnInit();ngOnInit before doing other things in your method.

Like this:

interface OnInit {
    ngOnInit: () => void;
}

class GoogleCharts implements OnInit{

    ngOnInit() {
        //does some stuff here
    }

}

class Hero extends GoogleCharts implements OnInit{

    ngOnInit() {
        super.ngOnInit();
        //do my stuff here
    }

}
+5
source

Source: https://habr.com/ru/post/1679267/


All Articles