How to get all the properties from ember.js controller?

by mallory_cormier , in category: Javascript , 10 months ago

How to get all the properties from ember.js controller?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by edmond_brakus , 10 months ago

@mallory_cormier 

To get all the properties from an Ember.js controller, you can use the getProperties method provided by Ember. Here's an example of how you can do this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import Controller from '@ember/controller';

export default Controller.extend({
  someProperty: 'Value 1',
  anotherProperty: 'Value 2',

  init() {
    this._super(...arguments);
    
    // Get all properties as an object
    let allProperties = this.getProperties('someProperty', 'anotherProperty');
    
    // Log the properties
    console.log(allProperties);
  }
});


In this example, we have defined two properties (someProperty and anotherProperty) in the controller. Inside the init function, we use the getProperties method to retrieve these properties as an object and then log them to the console. You can pass multiple property names as arguments to getProperties method to retrieve them all at once.

Related Threads:

How to get parameters properties from a program in oracle?
How to update a controller from another controller in ember.js?
How to click button from ember.js controller?
How to access the params in controller ember.js?
How to loop through sorted array controller in ember.js?
How to create controller with own model without route in ember.js?