Last active
February 6, 2017 17:44
-
-
Save kumkanillam/1f66e42b3b9e906ae395885474e3483d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: 'ul', | |
classNames: ['column-list'], | |
sortedItems: Ember.computed('items', 'sortBy', function() { | |
var sortByColumn = this.get('sortBy'); | |
if (this.get('sortBy') !== undefined) { | |
return this.get('items').sort(function(a,b){ | |
var nameA = a[sortByColumn].toUpperCase(); | |
var nameB = b[sortByColumn].toUpperCase(); | |
console.log(' nameA ',nameA, 'nameB ',nameB); | |
if (nameA < nameB) { | |
return -1; | |
} | |
if (nameA > nameB) { | |
return 1; | |
} | |
// names must be equal | |
return 0; | |
}); | |
} else { | |
return this.get('items'); | |
} | |
}), | |
actions:{ | |
changeSortBy(){ | |
this.set('sortBy','id'); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model(){ | |
return [ | |
{ | |
id: '3', | |
title: 'Main Dishes', | |
}, { | |
id: '2', | |
title: 'Cakes, Pies & Sweets', | |
}, { | |
id: '1', | |
title: 'angappie', | |
}, { | |
id: '4', | |
title: 'Dips & Sauces', | |
}, { | |
id: '5', | |
title: 'Meat Dishes', | |
}, { | |
id: '8', | |
title: 'Vegetable', | |
}, { | |
id: '6', | |
title: 'Seafood Dishes', | |
}, { | |
id: '7', | |
title: 'Bread & Cereals', | |
} | |
]; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.11.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment