2016-03-21 7 views
1

Ich versuche eine Glut-Anwendung, in der ich Mirage installiert habe und versuchte, den Server zu fälschen. Ich verwende einen RestAdapter, das Modell erhält die Daten der Antwort nicht.Store-Antwort auf Modell nicht zuordnen können - EmberJS

Adapter/application.js

import DS from 'ember-data'; 

export default DS.RESTAdapter.extend({ 
}); 

contacts.js (Modell)

import DS from 'ember-data'; 
import ContactModel from 'c360-app/models/contactsmodel'; 
export default ContactModel.extend({ 
    contactname: DS.attr(''), 
    groupid: DS.attr(''), 
    email: DS.attr(''), 
    contactnumber: DS.attr('') 
}); 

all.js (Route)

import ContactRoute from 'c360-app/routes/contactsroute'; 
export default ContactRoute.extend({ 
    model: function() { 
     return this.store.findAll('contacts'); 
    } 
}); 

Armaturen/contacts.js

export default [ 
    { 
     contactname: 'Anusha Swaminathan', 
     groupid: '12345', 
     email: '[email protected]', 
     contactnumber: '+91 12345', 
     isFavourite: true, 
     isIncomplete: false, 
     isActive: true, 
     hasAccess: true 
    }, { 
     contactname: 'Sriram Swaminathan', 
     groupid: '12345', 
     email: '[email protected]', 
     contactnumber: '+91 12345', 
     isFavourite: true, 
     isIncomplete: false, 
     isActive: true, 
     hasAccess: true 
    }, { 
     contactname: 'Bhuvaneswari Swaminathan', 
     groupid: '12345', 
     email: '[email protected]', 
     contactnumber: '+91 12345', 
     isFavourite: false, 
     isIncomplete: false, 
     isActive: true, 
     hasAccess: true 
    } 
]; 

Szenarien/Default.js

export default function(server) { 
    server.loadFixtures(); 
} 

config.js (Mirage)

export default function() { 
    this.get('/contacts', function(db){ 
    return {contacts: db.contacts}; 
    }); 
} 

kontakt listing.hbs

<table class = "contacts-table-header"> 
     <tr> 
      <th>Contact Name</th> 
      <th>Group ID </th> 
      <th>Email Address</th> 
      <th>Contact Number</th> 
     </tr> 
{{#each model as |contact|}} 
     <tr> 
      <td>{{contact.contactname}}</td> 
      <td>{{contact.groupid}}</td> 
      <td>{{contact.email}}</td> 
      <td>{{contact.contactnumber}}</td> 
     </tr> 

{{/each}} 
</table> 

Ich habe keine Ahnung, wo ich falsch liege.

Pls Anleitung. Danke im Voraus!!

+0

Können Sie sehen, alle Anfragen gefeuert und Antworten auf Ihrem Netzwerk-Tab in Entwickler-Tools? Verwenden Sie auch den Ember-Inspektor und können Sie sehen, dass das Modell mit Daten gefüllt wird? – Ms01

Antwort

0

In all.js (Route) Sie können versuchen mit return this.store.findAll ('contact'); und Modell Dateiname anstelle von contacts.js sagen contact.js

+0

Ok, lass mich es versuchen. Werden die Kontakte mit Inflector unzählbar sein? –