In Angular 4, how do I access the functions of the parent being in the child or the functions of the child being in the parent directly by the Typescript instead of traditionally accessing via tag attribute?
In Angular 4, how do I access the functions of the parent being in the child or the functions of the child being in the parent directly by the Typescript instead of traditionally accessing via tag attribute?
One partial solution I found was Create an abstract class! Put in it some abstract methods (as needed and required) and feed the constructor of the abstract class (my needs). That done, the screens (components) that I needed, started to extend this class.
Good morning Luiz Felipe, in the Angular can be created a service, once created a service it is an Injectable () and thus it can be passed in the constructors of the new classes in typescript. Using the CLI looks like this:
ng g s shared/servico1 --flat
(the flat not to create a folder)
and in your new typescript you can pass it on to the constructor and use it
construtor(private servi:servico1){
}