중첩 된 리소스가 경로 대신 경로 이름을 경로 이름으로 나열해야하는 이유를 설명 할 수 있습니까?Emberjs pre4 중첩 경로 기본 URI
예 : resource1> resource1.resource2
Emberjs는 코드 양을 줄이는 것 같습니다. 자원이 왜 이렇게 정의되어야 하는지를 설명하는 자원에 대한 사용 사례가 있습니까? 내가 jsfiddle 또는 jsbin에서 일을 내 예를 가져올 수 없습니다
그래서 여기가 주최 : http://emberjs.mattmazzola.net/
나는이 비슷한 StackOverflow의 질문에 설명 된 기술에서 내 솔루션을 내놓고 있었다가 여기에 있습니다 : Ember.js pre4 multiple nested routing
기본적으로 하위 리소스 '고양이'와 '개'가있는 '동물'리소스가 있다는 것을 알게되었습니다. 그러나 라우터에 "cats"와 "dogs"라는 이름 만 지정하면 라우터에서 "routes animals.cats"를 찾을 수 없습니다. 그런 다음 'animals'을 추가하면됩니다. 접두어로 중첩 된 라우트 'animals.cats'를 만들면 url은 index #/animals/animals.cats가됩니다. 물론 경로 속성을 재정 의하여이 문제를 해결할 수 있지만 Emberjs가 ' .? t이 기본적으로 이렇게 내가 잘못 내 자원/경로를 정의하고 있는데 이것은 측면에 영향을한다 즉
을, 나는 현재이 일을 해요 :
App.Router.map(function() {
this.resource('products', function() {
this.route('desktops');
this.route('laptops');
});
this.resource('animals', function() {
// the url for this route is bad, but default behavior?
this.resource('animals.cats', function() {
this.route('cat', {path: ':cat_id'});
});
// Why does this require stating the parent route 'animals' again?
this.resource('animals.dogs', {path: 'dogs/'}, function() {
this.route('dog', {path: ':dog_id'});
});
});
});
어떻게 할 수 다음과 같은 경로를 작성합니다 :
App.Router.map(function() {
this.resource('products', function() {
this.route('desktops');
this.route('laptops');
});
this.resource('animals', function() {
this.resource('cats', function() {
this.route('cat', {path: ':cat_id'});
});
this.resource('dogs', function() {
this.route('dog', {path: ':dog_id'});
});
});
});