Last active
April 16, 2016 05:49
-
-
Save zoltan-nz/eb79994c163dd1db4e2580cae066a318 to your computer and use it in GitHub Desktop.
download model in route
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.Controller.extend({ | |
| list: [], | |
| downloadedList: Ember.observer('model', function() { | |
| console.log('it is called'); | |
| const reposUrl = this.get('model.repos_url'); | |
| let buildList = [] | |
| let list = this.get('list'); | |
| Ember.$.get(reposUrl).then( | |
| (repos) => { | |
| console.log(repos); | |
| repos.forEach((repo) => {console.log(repo);buildList.push(repo.name);}); | |
| } | |
| ).then(() => this.set('list', buildList)); | |
| }) | |
| }); |
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'; | |
| import config from './config/environment'; | |
| const Router = Ember.Router.extend({ | |
| location: 'none' | |
| }); | |
| Router.map(function() { | |
| this.route('second'); | |
| }); | |
| export default Router; |
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 Ember.$.get('https://api.github.com/users/dulichan').then(data => Ember.$.get(data.repos_url).then(repos => repos.map(repo => repo.name))) | |
| } | |
| }); |
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 Ember.$.get('https://api.github.com/users/dulichan') | |
| } | |
| }); |
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.8.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.5.0", | |
| "ember-data": "2.5.1", | |
| "ember-template-compiler": "2.5.0" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment