When specifying a positional param for a component class in ember, you have to reopen the class (like below) so it will work, you cannot include it in the initial declaration (at least from what I've seen of examples and my own experience).
import Ember from 'ember';
const component = Ember.Component.extend({ });
component.reopenClass({
positionalParams: ['post'],
});
export default component;
If you do it in the single declaration (like below) it will not work
import Ember from 'ember';
export default Ember.Component.extend({
positionalParams: ['post'],
});
It just feels gross that I can't make it part of the same expression and have to assign the class to a variable, reopen it, then finally export it.
ember.js @ 2.2
The Annotate Schematics command systematically assigns designators to all or selected parts in selected sheets of a project and ensures that designators are unique and ordered based on their position.
An update can be caused by changes to props or state. These methods are called in the following order when a component is being re-rendered: static getDerivedStateFromProps() shouldComponentUpdate() render()
The DemoButtonHandler class implements the ActionListener interface, which requires an actionPerformed method with an ActionEvent parameter. The constructor stores the button that the event handler is listening to (this can also be accessed by event.
GUI Component classes, such as Button , TextField , and Label . GUI Container classes, such as Frame and Panel . Layout managers, such as FlowLayout , BorderLayout and GridLayout . Custom graphics classes, such as Graphics , Color and Font .
Is this because it's a class attribute of some kind?
This. The reopenClass
and extend
methods do not do the same thing.
Properties passed to reopenClass
are put on the constructor of the class itself:
MyClass = Ember.Object.extend({});
MyClass.reopenClass({ foo: 42 });
obj = MyClass.create();
console.log(obj.foo); // undefined
console.log(MyClass.foo); // 42
console.log(obj.constructor.foo); // 42
Properties passed to extend
, on the other hand, are available (*) on the instances:
MyClass = Ember.Object.extend({ foo: 42 });
obj = MyClass.create();
console.log(obj.foo); // 42
console.log(MyClass.foo); // undefined
console.log(obj.constructor.foo); // undefined
(*) I don't know whether they are copied or made part of the prototype chain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With