我想在Ember中做一個旋轉木馬滑塊,但我已經堆疊,因爲我不能讓Ember獲取我的圖像。在這裏我的代碼:Ember不顯示獲取模型
應用:
window.ArtRank = Ember.Application.create();
ArtRank.ApplicationAdapter = DS.FixtureAdapter.extend();
路由器:
ArtRank.Router.map(function(){
this.resource('index', {path: '/'}, function() {
this.resource("home", {path: '/'}, function() {
this.resource("photo", {path: '/photo'});
});
this.resource('categories', { path: "/categories" });
this.resource('profile', { path: "/profile" });
});
});
ArtRank.PhotoRoute = Ember.Route.extend({
model: function() {
return this.store.find('photo');
}
});
型號: 指數頁眉和頁腳和{{內:
ArtRank.Photo = DS.Model.extend({
imageTitle: DS.attr('string'),
imageUrl: DS.attr('string')
});
ArtRank.Photo.FIXTURES = [
{
id: 1,
imageTitle: 'Learn Ember.js',
imageUrl: 'http://getbootstrap.com/2.3.2/assets/img/bootstrap-mdo-sfmoma-01.jpg'
},
{
id: 2,
imageTitle: '...',
imageUrl: 'http://getbootstrap.com/2.3.2/assets/img/bootstrap-mdo-sfmoma-01.jpg'
},
{
id: 3,
imageTtitle: 'Profit!',
imageUrl: 'http://getbootstrap.com/2.3.2/assets/img/bootstrap-mdo-sfmoma-01.jpg'
}
];
我的模板被由outlet}}
Outelet通話home.hbs即:{{局部照片}}
home.hbs呈現photo.hbs那就是:
<div class="photos-wrap">
<h1>{{ imageTitle }}</h1>
<div class="photoItem">
<img id="photoItem" {{bind-attr src="imageUrl"}} />
</div>
</div>
任何建議非常感謝!
謝謝你,是一個很好的觀點,但不幸的是,這並不是問題,因爲與Ember檢查員一起看,我根本沒有得到日期。我的ArtRankPhoto爲空:( –
請嘗試更改資源定義:-) – Edu