私は2つのコンポーネントクラスAとBを持っています。typescriptは別のコンポーネントクラスからコンポーネントクラス変数にアクセスします
クラスAは多くのサービスを注入するために大きなコンストラクタを持っています。 iは[]にMSGをリセットする
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [ChatService]
})
export class HomePage {
chatRoot = ChatPage;
settingsRoot = SettingsPage;
constructor(private chatService: ChatService) {
}
onReset(){
//this.chatRoot.msg = [];
}
}
ような別の構成要素であるクラスBにおける
IonicPage()
@Component({
selector: 'page-chat',
templateUrl: 'chat.html',
providers: [ChatService]
})
export class ChatPage implements OnInit, OnDestroy{
msg:any[];
状アレイ。現在の状態では、私はmsgが知られていないことを告白します。
コンポーネント間の階層的な通信のための
@Input()
デコレータを使用してサービス