2014-06-17 1 views
2

다음과 같이 Ember VeteranRoute을 설정했습니다. 내 베테랑 모델에는 이름, 날짜, 정보 및 메달 속성이 있습니다. 베테랑의 이름에 액세스하려고하므로 activate 함수에서 볼 수 있듯이 제목 태그에 추가 할 수 있습니다.Ember.js - 경로 내의 활성화 기능에서 모델 속성에 액세스

콘솔의 콘솔에 this을 로그 아웃하면 볼 수있는 모든 데이터가 포함되어있는 다음이 표시됩니다.

Shows console log of "this"

가 어떻게 위의 데이터에서 이름 속성에 액세스 할 수 있습니다

? 다양한 this.Context._data.name 조합을 시도했지만 아무 것도 작동하지 않는 것 같습니다.

는 VeteranRoute

App.VeteranRoute = Ember.Route.extend({ 
    model: function(params){ 
     return this.store.find("veteran", params.veteran_id); 
    }, 
    activate: function() { 
     $(document).attr('title', this.veteran.name); 
     console.log(this); 
    } 
}); 

답변

3

setupController 또는 모델이 해결되었을 때 그리고 볼 수 있습니다 afterModel에서 할 app.js.

App.VeteranRoute = Ember.Route.extend({ 
    model: function(params){ 
     return this.store.find("veteran", params.veteran_id); 
    }, 
    setupController: function(controller, model) { 
     this._super(controller, model); 
     $(document).attr('title', model.get('name;)); 

    } 
}); 
관련 문제