I have two components in the same page. I have few methods and properties same for both components. How to use that by using a service. Below is a sample code...
@Component({
selector: 'app',
template: '<h1>AppComponent1</h1>'
})
export class AppComponent1 { }
@Component({
selector: 'appTwo',
template: '<h1>AppComponent2</h1>'
})
export class AppComponent2 { }
I have the below methods common for both:
onSearch(){
console.log('search');
}
onBtnClick(){
//do something
}
How to use a service to share between these two components which are on the same page.