我已经启动了小型 ember 应用程序,我有视图:
Cellar.SearchTextField = Ember.TextField.extend({
insertNewline: function(){
Cellar.SearchController.loadResults();
}
});
和控制器:
Cellar.SearchController = Ember.ArrayController.create({
content: [],
searchQuery: "",
loadResults: function() {
var me = this;
SC.get('/tracks', { q: me.get('searchQuery') }, function(tracks) {
me.set('content', []);
$(tracks).each(function(index, value){
var track = Cellar.Track.create({
id: value.id,
artwork: value.artwork_url,
download_url: value.download_url,
duration: value.duration,
stream_url: value.stream_url
})
me.pushObject(track);
});
});
}
});
和一个应用程序模板:
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container"></div>
<h3 class="logo">{{#linkTo "index"}}Cellar{{/linkTo}}</h3>
<form class="navbar-search">
{{view Cellar.SearchTextField placeholder="search" valueBinding="Cellar.SearchController.searchQuery"}}
</form>
</div>
</div>
</div>
<div id="content">
{{outlet}}
</div>
我的问题是当我在路线上时http://localhost:3000/
我searchController
不起作用,但是当 URL 是时一切正常http://localhost:3000/#/
,为什么?