Skip to content

Instantly share code, notes, and snippets.

@3gwebtrain
Created February 10, 2018 15:12
Show Gist options
  • Save 3gwebtrain/9ea6a6914190a6fe7ed9bad6fcabc5aa to your computer and use it in GitHub Desktop.
Save 3gwebtrain/9ea6a6914190a6fe7ed9bad6fcabc5aa to your computer and use it in GitHub Desktop.
Model Test
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Data Sharing'
});
import Collection from 'ember-cli-mirage/orm/collection';
export default function() {
window.server = this;
this.get('/foo', function (schema, request) {
var posts = [{
author: {name: 'Jane Eyre'}
}, {
author: {name: 'Emily Dickinson'}
}];
return posts;
});
this.get('/cards', function (schema, request) {
var cards = [{
"txnDate":"22/02/17",
"txnAmount":230000
},{
"txnDate":"6/07/16",
"txnAmount":180000
},{
"txnDate":"12/09/16",
"txnAmount":60000
}];
return cards;
});
this.get('/card-list', function (schema, request) {
var creditCards = [{
'cardName' : 'HDFC',
"cardNum' : 0099887788776655
},
{
'cardName' : 'Standard Chartered',
"cardNum' : 0099887788773333
},
{
'cardName' : 'ICICI Bank Ltd',
"cardNum' : 0099887788770022
}
];
return creditCards;
});
};
import Ember from 'ember';
export default Ember.Route.extend({
server: Ember.inject.service(),
model() {
return this.get('server.family')
}
});
import Ember from 'ember';
export default Ember.Service.extend({
family:Ember.computed(function(){
return $.get('/foo');
})
});
*{
margin:0;
padding:0;
}
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
li{
margin-bottom:1rem;
list-style:none;
}
<h1>Welcome to {{server.family}}</h1>
<br>
<br>
<ul>
{{#each model as |post|}}
<li>{{post.author.name}}</li>
{{/each}}
</ul>
<br>
<br>
{
"version": "0.13.0",
"ENV": {
"ember-cli-mirage": {
"enabled": true
}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3",
"ember-cli-mirage": "0.2.4"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment