本文整理汇总了TypeScript中ember-metal.computed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript computed函数的具体用法?TypeScript computed怎么用?TypeScript computed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了computed函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: computed
/**
Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass`
CSS `class` to the element when the link is disabled.
When `true` interactions with the element will not trigger route changes.
@property disabled
@private
*/
disabled: computed({
get(_key: string): boolean {
// always returns false for `get` because (due to the `set` just below)
// the cached return value from the set will prevent this getter from _ever_
// being called after a set has occured
return false;
},
set(_key: string, value: any): boolean {
this._isDisabled = value;
return value ? get(this, 'disabledClass') : false;
},
}),
_isActive(routerState: any) {
if (get(this, 'loading')) { return false; }
let currentWhen = get(this, 'current-when');
if (typeof currentWhen === 'boolean') { return currentWhen; }
let isCurrentWhenSpecified = !!currentWhen;
示例2: computed
/**
The `type` attribute of the input element.
@property type
@type String
@default "text"
@public
*/
type: computed({
get(): string {
return 'text';
},
set(_key: string, value: string) {
let type = 'text';
if (canSetTypeOfInput(value)) {
type = value;
}
return type;
},
}),
/**
The `size` of the text field in characters.
@property size
@type String
@default null
@public