回答編集履歴

3

追記

2016/06/22 09:27

投稿

syuilo
syuilo

スコア393

test CHANGED
@@ -39,3 +39,7 @@
39
39
 
40
40
 
41
41
  ではダメですか?
42
+
43
+
44
+
45
+ ご質問が、動的にルーティングしたいという旨なのでしたら、そのためのパスマッチング構文がありますのでそれを用います。

2

Improve readavility

2016/06/22 09:27

投稿

syuilo
syuilo

スコア393

test CHANGED
@@ -4,9 +4,25 @@
4
4
 
5
5
 
6
6
 
7
+ router.get('/test1', (req, res) => {
8
+
9
+ res.render('test1');
10
+
11
+ });
12
+
13
+
14
+
15
+ router.get('/test2', (req, res) => {
16
+
17
+ res.render('test2');
18
+
19
+ });
20
+
21
+
22
+
7
23
  router.get('/test1/routeA', (req, res) => {
8
24
 
9
- res.render('testa/routeA', {});
25
+ res.render('testa/routeA');
10
26
 
11
27
  });
12
28
 
@@ -14,7 +30,7 @@
14
30
 
15
31
  router.get('/test1/routeB', (req, res) => {
16
32
 
17
- res.render('testa/routeB', {});
33
+ res.render('testa/routeB');
18
34
 
19
35
  });
20
36
 

1

Add comment

2016/06/22 09:17

投稿

syuilo
syuilo

スコア393

test CHANGED
@@ -1,4 +1,8 @@
1
1
  ```JavaScript
2
+
3
+ // index.js
4
+
5
+
2
6
 
3
7
  router.get('/test1/routeA', (req, res) => {
4
8