私は2つのコンポーネントnavbarとloginを持っていますが、ログインコンポーネントのnavbarで関数を呼びたいと思いますが、これまでに試してみましたが...... did352私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;
}
}
私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();
}
私はプロバイダを使用しますが、私は助けをしてください示唆これらprocess.Can誰もわからないです。
はこれに私の質問を参照してください - http://stackoverflow.com/questions/40219356/transferring-data-between-non-nested-components?noredirect=1#comment67766817_40219356 その呼び出しのプロパティがありますが、同じような機能を呼び出すことができます。残念ながら私は解決していない問題に陥っています。たぶんあなたは知っているかもしれません – Manoj