Currently tackling my first ember application, which consists of two pages: the Welcome page and a page displaying student details. To accomplish this, I have established two routes named index and studentdb. Unfortunately, I'm encountering an issue where the second page is not being displayed correctly. Utilizing Mirage in accordance with Ember's guidelines. Here's a snippet of the relevant code:
templates/index.hbs
<h1> Welcome </h1>
{{#link-to "studentdb"}}List{{/link-to}}
{{outlet}}
templates/studentdb.hbs
<h2> Welcome to Student Database </h2>
<h4> Following are the details </h4>
{{#each model as |student|}}
<p>Name: {{student.Name}}</p>
<p>College: {{student.College}}</p>
<p>Department: {{student.Department}}</p>
{{/each}}
{{outlet}}
routes/studentdb.js
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.findAll('student');
}
});
models/student.js (model)
import DS from 'ember-data';
export default DS.Model.extend({
Name: DS.attr(),
College: DS.attr(),
Department: DS.attr()
});
mirage/config.js
export default function() {
this.get('/student', function() {
return {
data: [{
type: 'student',
id: 1,
attributes: {
Name: 'Archana',
College: 'MNM Jain',
Department: 'CSE'
}
}, {
type: 'student',
id: 2,
attributes: {
Name: 'Monica',
College: 'Sathyabama',
Department: 'IT'
}
}, {
type: 'student',
id: 3,
attributes: {
Name: 'Manoj',
College: 'Kumarsaamy',
Department: 'MECH'
}
}]
}
});
}
router.js
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('studentdb');
});
export default Router;
If anyone can provide assistance, it would be greatly appreciated.
Encountering errors even after re-installing Ember based on the instructions outlined here: https://github.com/ember-cli/ember-cli/releases
npm WARN deprecated [email protected]: This package is no longer maintained. See its readme for upgrade details. npm ERR! registry error parsing json npm ERR! registry error parsing json npm ERR! registry error parsing json npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "[email protected]"npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! http://github.com/npm/npm/issues
npm ERR! Please include the following file with any support request: npm ERR! C:\Users\learner\npm-debug.lo
Any assistance would be greatly appreciated.