我正在尝试同步视图中显示的变量,但没有任何反应。我创建了一个 JSFiddle http://jsfiddle.net/HKgYn/1/
<script type="text/x-handlebars" data-template-name="photo_album">
<!-- I want view.cover to be updated automatically but nothing happens? -->
My Cover: {{ view.cover }}
</script>
App.PhotoAlbumController = Ember.ObjectController.extend({
cover: '/no-image.jpg'
});
App.PhotoAlbumView = Ember.View.extend({
coverBinding: 'App.photoAlbumController.cover'
});
App.AlbumController = Ember.ObjectController.extend({
needs: ['photoAlbum']
});
App.AlbumRoute = Ember.Route.extend({
setupController: function(controller, model) {
var pac = controller.get('controllers.photoAlbum');
pac.set('cover', model.get('cover_url'));
},
model: function(params) {
return App.Album.find(params.album_id);
}
});
我不确定我错过了什么或我做错了什么,非常需要一些帮助。
谢谢。