当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ember-metal.computed函数代码示例

本文整理汇总了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;
开发者ID:GowthamMK,项目名称:ember.js,代码行数:31,代码来源:link-to.ts

示例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
开发者ID:Artmann,项目名称:ember.js,代码行数:31,代码来源:text_field.ts


注:本文中的ember-metal.computed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。