質問編集履歴
2
要点が伝わりやすいように表現の変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
angular4.0のrouter-outletを使用した際の親子間の値の受け渡し
|
body
CHANGED
@@ -1,12 +1,23 @@
|
|
1
1
|
動作:[https://toparent.herokuapp.com/](https://toparent.herokuapp.com/)
|
2
2
|
ソース:[https://github.com/kuniatsu/routerQuestion](https://github.com/kuniatsu/routerQuestion)
|
3
3
|
|
4
|
-
親コンポーネントで
|
4
|
+
親コンポーネントでrouter-outletを使用して表示する際の子コンポーネントとの値の受け渡し方法がわかりません。
|
5
5
|
|
6
|
-
selectorを使用した場合は、@Outputで親コンポーネントのメソッドを渡すことによって親との値のやり取りができますが、他のコンポーネントも共通するRouterの場合どのようにしたら良いでしょうか?
|
7
6
|
|
7
|
+
```ここに言語を入力
|
8
|
+
<router-outlet (onVoted)="onVoted($event)"></router-outlet><!--不可-->
|
9
|
+
<app-child1 (onVoted)="onVoted($event)"></app-child1><!--可-->
|
8
10
|
|
11
|
+
```
|
12
|
+
selectorを使用した場合は、@Outputで親コンポーネントのメソッドを渡すことによって親との値のやり取りができますが、他のコンポーネントも共通するrouter-outletの場合どのようにしたら良いでしょうか?
|
9
13
|
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
10
21
|
下記では、Routerで表示している子コンポーネントのボタンは動かず、selectorで表示しているボタンは動作し、タイトルに1を加えます。
|
11
22
|
親.ts
|
12
23
|
```ここに言語を入力
|
1
リンクに変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
動作:https://toparent.herokuapp.com/
|
2
|
-
|
1
|
+
動作:[https://toparent.herokuapp.com/](https://toparent.herokuapp.com/)
|
2
|
+
ソース:[https://github.com/kuniatsu/routerQuestion](https://github.com/kuniatsu/routerQuestion)
|
3
3
|
|
4
4
|
親コンポーネントでRouterを使用して表示する際の子コンポーネントとの値の受け渡し方法がわかりません。
|
5
5
|
|