Function

bool (dependentKey) ComputedProperty public

Module: @ember/object
import { bool } from '@ember/object/computed';
dependentKey
String
returns
ComputedProperty
computed property which converts to boolean the original value for property

A computed property that converts the provided dependent property into a boolean value.

let Hamster = Ember.Object.extend({
  hasBananas: Ember.computed.bool('numBananas')
});

let hamster = Hamster.create();

hamster.get('hasBananas'); // false
hamster.set('numBananas', 0);
hamster.get('hasBananas'); // false
hamster.set('numBananas', 1);
hamster.get('hasBananas'); // true
hamster.set('numBananas', null);
hamster.get('hasBananas'); // false

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