Forked from carlbennettnz/application.controller.js
          
        
    
          Last active
          September 9, 2015 04:39 
        
      - 
      
- 
        Save KTKate/6180b7d2733997af86b5 to your computer and use it in GitHub Desktop. 
    Adding to a RecordArray
  
        
  
    
      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'; | |
| import DS from 'ember-data'; | |
| const {$} = Ember; | |
| export default Ember.Route.extend({ | |
| init() { | |
| this._super(...arguments); | |
| $.mockjax({ | |
| url: "/users", | |
| responseText: { | |
| users: [{ | |
| id: '1', | |
| name: 'john' | |
| }, | |
| { | |
| id: '2', | |
| name: 'bob' | |
| }], | |
| } | |
| }); | |
| }, | |
| model(){ | |
| return this.store.query('user', {name: 'phil'}).then((users) => { | |
| this.set('userList', users); | |
| return users; | |
| }); | |
| }, | |
| setupController(controller, model){ | |
| this._super(...arguments); | |
| controller.set('userList', this.get('userList')); | |
| }, | |
| actions: { | |
| newUser(){ | |
| let phil = this.store.createRecord('user', {name: 'phil'}); | |
| console.log('userList', this.get('userList')); | |
| this.get('userList.content').push(phil); | |
| } | |
| } | |
| }); | 
  
    
      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 DS from 'ember-data'; | |
| export default DS.Model.extend({ | |
| name: DS.attr('string') | |
| }); | 
  
    
      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'; | |
| var Router = Ember.Router.extend({ | |
| location: config.locationType | |
| }); | |
| Router.map(function() { | |
| this.route('index', {path: '/'}); | |
| }); | |
| 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
    
  
  
    
  | { | |
| "version": "0.4.10", | |
| "dependencies": { | |
| "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
| "ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js", | |
| "ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js", | |
| "ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js", | |
| "jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js" | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment