I'm new to EmberJS, I set up a simple project using ember-cli and I have the following code in my app: routes/person.js
import Ember from "ember";
export default Ember.Route.extend({
setupController: function(controller, person) {
controller.set('model', person);
},
model: function() {
return this.store.find('person', 1); // returns a promise that will resolve
},
});
models/person.js
import DS from "ember-data";
let Person = DS.Model.extend({
name: DS.attr('string'),
birthDate: DS.attr('string'),
});
Person.reopenClass({
FIXTURES: [
{ id: 1, name: 'Jack Sparrow', birthDate: 'Glowacki' },
{ id: 2, name: 'Long John Silver' , birthDate: 'Dale' }
]
});
export default Person;
controllers/person.js
import Ember from "ember";
export default Ember.ObjectController.extend({
findPerson: function(){
//do a HTTP call to the mzalendo API
},
});
router.js
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
export default Router.map(function() {
this.route('person', { path: '/person' });
});
templates/person.hbs
<strong>Name: {{name}} </strong>
When I run the server and go to http://localhost:4200/persons nothing loads and there's no error, am I missing something here?
Aucun commentaire:
Enregistrer un commentaire