2014-01-16 2 views
1

내 응용 프로그램에 중첩 템플릿이 있습니다. 어느 아래의 라우터에 의해 표시됩니다 : @ kingpin2k에Ember.js 중첩 된 경로를 찾을 수 없습니다.

this.resource('products', function() { 
    this.resource('product', {path: ':product_id'}, function() { // Error: There is no route named product 
     this.resource('page', {path: 'page/:page_id'}); 
    }); 
}); 

명예를이 라우터에 그의 도움 : 제품의 경로를 찾을 수 있습니다 Ember.js How to show two routes at the same time

문제는, 페이지 자원없이. 내가 페이지 리소스를 추가 할 때 product.index 노선 내가 엠버 Inspector에서 보는 바와 같이 제품 경로 지금 올바른 URL이 있습니다

경로와 URL의 :

`product`  | (empty) 
`product.index` | /products/:product_id // this one must be on the above `product` route 
`page`   | /products/:product_id/page/:page_id // correct 

당신이 볼 수 있듯이, 새로운 product.index 문제를 일으키고있다. 그러나 .index 변형은 페이지 경로를 추가 할 때만 나타납니다.

편집 : Error: There is no route named product : 내가 오류가 위의 라우터, clearify합니다. 그 오류가 발생 코드가보기에 :

var router = self.get('controller.target.router'); 
var product = self.get('content').findBy('index', 0); 

router.transitionTo('product', product); // Error 
+1

을 다할 것 대신 객체의 문자열로'products' '와''product''을 할 경우, 수행 작동합니까? – claptimes

+0

+1 그 말은 오타였습니다! –

답변

1

는이

var controller = self.get('controller'); 
var product = self.get('content').findBy('index', 0); 

controller.transitionToRoute('product', product); 
관련 문제