What is the difference between set (this, 'agentName', 'John') and this.set ('agentName', 'John') in Ember?

The same is true for get methods. Similarly get(this, 'agentName'), it this.get('agentName')returns the same value.

In the official ember doc for the get method, it shows that we must pass 2 values ​​to receive. Then how this.get('agentName')exactly works?

0
source share
2 answers

this.get(...)is a shortcut for Ember.get(this,...). However, it is available only for ember objects, therefore it only Ember.getworks in simple js objects.

Take a look at the this.get(...)implementation .

+3
source

Ember unknown property, computed property observers. setUnknownProperty() unknownProperty() get set, . observers.

, set() this.set() . set(), -, . Howeve, this.set() this. , , . , , this component. , ember. - ember, this , JavaScript. , getter setter JavaScript.

, get(this, 'foo'), getter JavaScript . this.get('foo'), get() Ember.Object, , . @Lux this.get('foo'), Ember.get(, 'foo').

, . Ember guide API docs. curent ember-cli ember-data - @2.12.0

+2

Source: https://habr.com/ru/post/1674372/


All Articles