How to show data from model in a view?


#1

Im wondering here, how to show models data e.g Organization model>name field in ember view I tried something like this.

organization VIEW

 OrganizationComputedProperty: function(){
          console.log("this is org OrganizationComputedProperty");
          var org = {
          orgname: this.get('controller.organizations')
          };
        }.property('orgname'),

Model

var Organization = DS.Model.extend({
    name: DS.attr('string'),
    address: DS.belongsTo('agents/address')
});

// Initial data for Organization model, only applies when using
Organization.FIXTURES = [
 {
   id: 1,
   name: 'TU',
   address: 1,
 },
  {
   id: 2,
   name: 'TLU',
   address: 2,
 }
 ];

Main hbs

{{#each personFormCount}}
{{view 'organization'}}
{{/each}}

Controller

personFormCount: [{id: 1}, {id: 2}]

But i know that’s wrong, because they watch for changing behaviours which don’t take place in model…

Cheers,


#2

Since i was capable of getting model to my view by this.get('controller.organizations') Which is defined in route

controller.set('organizations', this.store.findAll('agents/organization'));

I looked at the select once again

{{view Ember.Select
contentBinding="organizations"
optionValuePath="content.id"
optionLabelPath="content.name"
selectionBinding="selectedAgent"
class="form-control"
}}

And i just added controller.organizations to contentBinding

{{view Ember.Select
contentBinding="controller.organizations"
optionValuePath="content.id"
optionLabelPath="content.name"
selectionBinding="selectedAgent"
class="form-control"
}}