Function

alias (dependentKey) ComputedProperty public

Module: @ember/object
import { alias } from '@ember/object/computed';
dependentKey
String
returns
ComputedProperty
computed property which creates an alias to the original value for property.

Creates a new property that is an alias for another property on an object. Calls to get or set this property behave as though they were called on the original property.

Example:

import { set } from '@ember/object';
import { alias } from '@ember/object/computed';

class Person {
  name = 'Alex Matchneer';

  @alias('name') nomen;
}

let alex = new Person();

alex.nomen; // 'Alex Matchneer'
alex.name;  // 'Alex Matchneer'

set(alex, 'nomen', '@machty');
alex.name;  // '@machty'

Classic Class Example:

import EmberObject, { set } from '@ember/object';
import { alias } from '@ember/object/computed';

let Person = EmberObject.extend({
  name: 'Alex Matchneer',

  nomen: alias('name')
});

let alex = Person.create();

alex.nomen; // 'Alex Matchneer'
alex.name;  // 'Alex Matchneer'

set(alex, 'nomen', '@machty');
alex.name;  // '@machty'

© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/3.25/functions/@ember%2Fobject%2Fcomputed/alias