タグ付けされた質問 「event-delegation」

7
委任:AngularでのEventEmitterまたはObservable
Angularで委任パターンのようなものを実装しようとしています。ユーザーがをクリックnav-itemすると、次にイベントをリッスンする関数を呼び出して、イベントをリッスンする他のコンポーネントによって処理されるイベントを生成したいと思います。 これがシナリオです:私はNavigationコンポーネントを持っています: import {Component, Output, EventEmitter} from 'angular2/core'; @Component({ // other properties left out for brevity events : ['navchange'], template:` <div class="nav-item" (click)="selectedNavItem(1)"></div> ` }) export class Navigation { @Output() navchange: EventEmitter<number> = new EventEmitter(); selectedNavItem(item: number) { console.log('selected nav item ' + item); this.navchange.emit(item) } } これが観測コンポーネントです: export class …

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.