I want to call a function of component from template of another component in
ionic 2.I get a dashboard in in my app dashboard.html using home.ts
component.
<ion-content>
<div class="dashboardSection">
<a href="" (click)="fetchAllClass()">
<div class="header padding text-center classes common">
<img src="assets/images/icos_15.png" alt="Your logo here" width="50%" height="auto"/>
<p class="Sectiontitle">STUDENTS</p>
</div>
</a></div>
</ion-content>
this is showing with the help of home.ts
doLogin(event) {
var user1 =this.loginForm.value;
var password = this.loginForm.controls.password.value;
this.homeService.doLogin(user1).subscribe(
user =>{
this.user = user.results;
this.storage.set('isLoggedIn', 'shahjad');
this.navCtrl.setRoot(DashboardComponent, {thing1: user });
},
err => {
console.log(err);
},
() => console.log('login complete')
);
}
Now, I want to call student component'function from dashboard Component
I created student component like students.ts
@Component({
selector: 'page-students',
templateUrl: "./students.html"
})
export class StudentsComponent {
dashboardItem: any;
mode = "Observable";
errorMessage: string;
constructor(public fb: FormBuilder,private studentsService: StudentsService,public navCtrl: NavController,private storage: Storage,private menu: MenuController) {}
fetchAllClass(event) {
alert("fd");
}
}