ember-controllers

Ember passing a model to transitionToRoute

我们两清 提交于 2019-12-12 13:33:46
问题 I'm using Ember-cli with ember 1.11 I'm trying to use the transitionToRoute method in a controller to transition to a route and feed it a dynamically generated object as the model. Here's my controller: import Ember from 'ember'; export default Ember.Controller.extend({ actions: { launch_scanner: function(){ console.log('launch_scanner'); var model = {name: "Edward", phone: "123", email: "email@test.com"}; //the final app will pull the model variable from a QR scanner this.transitionToRoute(

Sort Ember Object Array with Promises

无人久伴 提交于 2019-12-11 10:57:12
问题 I have a model model/person { firstName: DS.attr( 'string'), lastName: DS.attr( 'string'), email: DS.attr( 'string' ), } and another model model/project { name: DS.attr( 'string' ), code: DS.attr( 'string' ), startDate: DS.attr( 'date' ), endDate: DS.attr( 'date' ), users : DS.hasMany('person', {async: true}), } then i'm retrieving all the projects with as an array which contains ember objects. since the project -> users is async its a promise. and i want to sort that array using the first

Replace Ember.ArrayController.create() will not resolve belongTo relationships | ember upgrade 3.x

戏子无情 提交于 2019-12-11 05:37:26
问题 I'm in the process of upgrading and I'm facing issues because ArrayController is being deprecated. In my old Ember 1.13 route I'm using model/announcement.js export default DS.Model.extend( { id:DS.attr('string'), title: DS.attr( 'string' ), description: DS.attr( 'string' ), published: DS.attr( 'boolean' ), publishedAt: DS.attr( 'date' ), course: DS.belongsTo( 'course' ), author: DS.belongsTo( 'profile', { async: true } ), viewed: false, isNew: true, } serializer/announcement.js import DS

Calculate sub total emberjs

我们两清 提交于 2019-12-11 02:33:53
问题 I create a shop cart. I using fixture adapter. My models App.Clothing = DS.Model.extend({ name: DS.attr('string') , category: DS.attr('string') , img: DS.attr('string') , price: DS.attr('number') , num: DS.attr('number') , fullPrice: function(){ return this.get('price') + " $"; }.property('price') }) App.CartRecord = App.Clothing.extend({ numInCart:DS.attr('number',{defaultValue:1}) , fullPrice: function(){ return this.get('price')*this.get('numInCart'); }.property('numInCart','price') }) App

Ember 2, filter relationship models (hasMany, belongsTo) and calculate computed property based on relationships

梦想与她 提交于 2019-12-08 18:48:14
问题 These are my files: Models app/models/basket.js: export default DS.Model.extend({ name: DS.attr('string'), house: DS.belongsTo('house', { async: true }), boxes: DS.hasMany('box', { async: true }) }); app/models/box.js: export default DS.Model.extend({ qty: DS.attr('number'), basket: DS.belongsTo('basket'), cartLines: DS.hasMany('cart-line', { async: true }) }); app/models/cart-line.js: export default DS.Model.extend({ qty: DS.attr('number'), box: DS.belongsTo('box'), product: DS.belongsTo(

Calling a controllers method in another controller Ember

亡梦爱人 提交于 2019-12-04 21:45:34
问题 I am using Ember's Need Api to call a method of a controller in another controller. I am able to get the instance of the controller but when I am calling it method it returns me this error TypeError: Object [object Object] has no method. This is how I am calling it: Cards.CardsIndexController = Ember.Controller.extend({ needs: 'account_info', actions: { accountInfoStart:function(){ console.log(this.get('controllers.account_info').test()); // error here } } }); This is the controller whose

Calling a controllers method in another controller Ember

筅森魡賤 提交于 2019-12-03 13:25:28
I am using Ember's Need Api to call a method of a controller in another controller. I am able to get the instance of the controller but when I am calling it method it returns me this error TypeError: Object [object Object] has no method. This is how I am calling it: Cards.CardsIndexController = Ember.Controller.extend({ needs: 'account_info', actions: { accountInfoStart:function(){ console.log(this.get('controllers.account_info').test()); // error here } } }); This is the controller whose function I want to call Cards.AccountInfoController = Ember.Controller.extend({ actions:{ test: function()

EmberJS actions - call one action from another when wrapped within `actions`

▼魔方 西西 提交于 2019-12-03 06:28:36
问题 How do you call one action from another action when wrapped within actions in an EmberJS controller? Original code that uses the now deprecated way to define actions: //app.js App.IndexController = Ember.ArrayController.extend({ // properties /* ... */ // actions actionFoo: function() { /* ... */ this.actionBar(); }, actionBar: function() { /* ... */ } }); //app.html <div class="foo" {{action actionFoo this}}> <div class="bar" {{action actionBar this}}> However, with EmberJS 1.0.0, we get a

EmberJS actions - call one action from another when wrapped within `actions`

爷,独闯天下 提交于 2019-12-02 19:58:54
How do you call one action from another action when wrapped within actions in an EmberJS controller? Original code that uses the now deprecated way to define actions: //app.js App.IndexController = Ember.ArrayController.extend({ // properties /* ... */ // actions actionFoo: function() { /* ... */ this.actionBar(); }, actionBar: function() { /* ... */ } }); //app.html <div class="foo" {{action actionFoo this}}> <div class="bar" {{action actionBar this}}> However, with EmberJS 1.0.0, we get a deprecation warning, saying that actions must be put within an actions object within the controller,