Proxy content to another controller Solution
Try with local storage adapter
by Nairam
HTML
<script src="http://builds.emberjs.com/handlebars-1.0.0-rc.4.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script src="http://builds.emberjs.com.s3.amazonaws.com/ember-data-latest.js"></script>
<script src="http://downloads.netobjects.com/mobile/ember/localstorage_adapter.js"></script>
<script type="text/x-handlebars" data-template-name="application">
<label>Input name:</label>
{{view Ember.TextField valueBinding="name" }}
<button {{action "save"}}>Save Data</button>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<p>Names:</p>
{{#each item in controller }}
<p>{{item.name}}</p>
{{/each}}
{{#linkTo "start" }}Go to Start{{/linkTo}}
</script>
<script type="text/x-handlebars" data-template-name="start">
<p>You are on start</p>
{{#each item in contentFromOtherController }}
<p>{{item.name}}</p>
{{/each}}
<button {{action "alert"}}>Show Alert</button>
</script>
JavaScript
App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 12,
adapter: DS.LSAdapter.create()
});
App.Data = DS.Model.extend({
name: DS.attr('string')
});
App.Router.map(function() {
this.route("start");
});
App.ApplicationController = Ember.ObjectController.extend({
save: function() {
this.get("model.transaction").commit();
this.get("target").transitionTo("index");
}
});
App.ApplicationRoute = Ember.Route.extend({
model: function() {
return App.Data.createRecord();
}
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.Data.find();
}
});
App.StartRoute = Ember.Route.extend({});
App.IndexController = Ember.ArrayController.extend({
sortProperties: ["id"],
sortAscending: true
});
App.StartController = Ember.ObjectController.extend({
needs: 'index',
contentFromOtherController: function(){
// if you want to get the sorted content from the other
// controller take "arrangedContent"
return this.get("controllers.index.arrangedContent");
}.property("controllers.index.content"),
alert: function() {
// get the "content" from the IndexController;
var names = this.get("controllers.index.arrangedContent");
alert(names.objectAt(0).name);
}
});