ユーザーが を入力する必要がある開始ページがありますapiKey
。そのフォーム データを使用して、それをルートに渡します。deals
ルートは、入力された に基づいて関連データをフェッチしますapiKey
。
私の問題はapiKey
、URI で を使用して取引ページを直接読み込むと正常に動作することですが、start
ページのフォームから を使用して送信するとapiKey
、次のエラーが発生します。
Uncaught Error: assertion failed: an Ember.CollectionView's content must implement Ember.Array. You passed 'asdf'
app.js は次のとおりです。
App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 12,
adapter: 'DS.FixtureAdapter'
});
App.Deal = DS.Model.extend({
name: DS.attr('string')
});
App.Deal.FIXTURES = [
{id: 1, name: 'Deal 1'},
{id: 2, name: 'Deal 2'}
]
App.Router.map(function() {
this.resource('start', { path: '/' });
this.resource('deals', { path: '/deals/:api_key' });
});
App.StartController = Ember.ObjectController.extend({
apiKey: '',
getDeals: function (model) {
this.transitionToRoute('deals', this.apiKey);
}
});
App.DealsRoute = Ember.Route.extend({
model: function() {
// return App.Deal.getWonFor(params.api_key);
return App.Deal.find();
}
});
App.DealController = Ember.ArrayController.extend({
});
App.DealsView = Ember.View.extend({
didInsertElement: function() {
// Add active class to first item
this.$().find('.item').first().addClass('active');
this.$().find('.carousel').carousel({interval: 1000});
}
});
HTMLは次のとおりです。
<script type="text/x-handlebars">
<h2>Won Deal Ticker</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="start">
{{view Em.TextField valueBinding="apiKey" placeholder="API Key" action="getDeals" }}
<br />
<button {{action 'getDeals' apiKey}} class="btn btn-large">Get Won Deals!</button>
</script>
<script type="text/x-handlebars" data-template-name="deals">
<div id="carousel" class="carousel slide">
<div class="carousel-inner">
{{#each model}}
<div class="item">
{{name}}
</div>
{{/each}}
</div>
</div>
</script>