I have 2 components navbar and login,I want to call a function in navbar in login component and so far i tried this but did'nt worked...... My navbar.ts,
import {Component, OnInit} from '@angular/core';
@Component({
selector: 'header-Navbar',
templateUrl: './app/navbar/navbar.html',
})
export class Navbar implements OnInit {
constructor(public router: Router) {
}
get(){
if (this.user == null) {
this.showstartupbuttons = true;
this.showsicons = false;
}
else {
this.username = this.user.username;
this.showsicons = true;
this.showstartupbuttons = false;
}
}
My login.ts,
import {Component, OnInit} from '@angular/core';
@Component({
templateUrl: './app/login/login.html',
providers:[Navbar]
})
export class Login implements onInit{
ckeditorContent:any;
constructor(public navbar:Navbar) {}
ngOnInit(){
this.navbar.get();
}
I used providers but i am not sure about these process.Can anyone suggest help please.