I have a route / companies route that uses my Company model to retrieve companies. I also have a map view on which I am trying to show my companies. I can’t find a way to get the list of companies inside the view.
In the code below, the map is displayed as expected, and company names are printed as paragraphs.
window.App = Ember.Application.create() App.Router.map -> @resource 'companies' App.CompaniesRoute = Ember.Route.extend model: -> App.Company.find() App.Map = Ember.View.extend tagName: 'div' didInsertElement: -> opts = zoom: 12 center: new google.maps.LatLng 37.762030, -122.441940 mapTypeId: google.maps.MapTypeId.ROADMAP e = @get 'element' m = new google.maps.Map e, opts
My template looks like this:
{{#each model}} <p>{{name}}</p> {{/each}} {{view App.Map}}
All company names are displayed, I just can’t find a way to keep the model / content from the view.
So far I have tried @get 'model' from didInsertElement . I tried to create the markersBinding property in a view with a number of inputs, such as "controller.content" and "controller.model" and "route.model" - all to no avail. I also tried adding another method to the view, which oversees each of the attempts that I tried.
I feel like I'm missing something. How can I subscribe / watch content / model in a view?
Thanks.
source share