Function

equal (dependentKey, value) ComputedProperty public

Module: @ember/object
import { equal } from '@ember/object/computed';
dependentKey
String
value
String|Number|Object
returns
ComputedProperty
computed property which returns true if the original value for property is equal to the given value.

A computed property that returns true if the provided dependent property is equal to the given value.

Example:

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

class Hamster {
  @equal('percentCarrotsEaten', 100) satisfied;
}

let hamster = new Hamster();

hamster.satisfied; // false

set(hamster, 'percentCarrotsEaten', 100);
hamster.satisfied; // true

set(hamster, 'percentCarrotsEaten', 50);
hamster.satisfied; // false

Classic Class Example:

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

let Hamster = EmberObject.extend({
  satisfied: equal('percentCarrotsEaten', 100)
});

let hamster = Hamster.create();

hamster.satisfied; // false

set(hamster, 'percentCarrotsEaten', 100);
hamster.satisfied; // true

set(hamster, 'percentCarrotsEaten', 50);
hamster.satisfied; // false

© 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/equal