本文整理汇总了TypeScript中@ember/component/helper.helper函数的典型用法代码示例。如果您正苦于以下问题:TypeScript helper函数的具体用法?TypeScript helper怎么用?TypeScript helper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了helper函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: first8
import { helper as buildHelper } from '@ember/component/helper';
export function first8(params: any[] /*, hash*/) {
return params[0].substring(0, 8);
}
export const helper = buildHelper(first8);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:7,代码来源:first-8.ts
示例2: or
import { helper as buildHelper } from '@ember/component/helper';
export function or(params: any[] /*, hash*/) {
return params[0] || params[1];
}
export const helper = buildHelper(or);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:7,代码来源:or.ts
示例3: splitText
import { helper } from '@ember/component/helper';
export function splitText([string = '', maxLen = 20, separator = '...']: [string, number?, string?]): string {
const { length: strLen } = string;
const { length: sepLen } = separator;
if (strLen > maxLen) {
const splitLen = Math.floor((maxLen - sepLen) / 2);
return `${string.substr(0, splitLen).trim()}${separator}${string.substr(-splitLen).trim()}`;
}
return string;
}
export default helper(splitText);
开发者ID:alyiwang,项目名称:WhereHows,代码行数:16,代码来源:split-text.ts
示例4: isPresent
import { helper as buildHelper } from '@ember/component/helper';
import { isPresent as eIsPresent } from '@ember/utils';
export function isPresent(params: any[] /*, hash*/) {
return eIsPresent(params[0]);
}
export const helper = buildHelper(isPresent);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:8,代码来源:is-present.ts
示例5: function
class SessionService extends Ember.Service {
currentUser: User;
}
const CurrentUserEmailHelper = Ember.Helper.extend({
session: Ember.inject.service() as Ember.ComputedProperty<SessionService>,
onNewUser: Ember.observer('session.currentUser', function(this: Ember.Helper) {
this.recompute();
}),
compute(): string {
return this.get('session')
.get('currentUser')
.get('email');
},
});
import { helper } from '@ember/component/helper';
function typedHelp(/*params, hash*/) {
return 'my type of help';
}
export default helper(typedHelp);
function arrayNumHelp(/*params, hash*/) {
return [1, 2, 3];
}
helper(arrayNumHelp);
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:29,代码来源:helper.ts
示例6: and
// https://github.com/DockYard/ember-composable-helpers/blob/master/addon/helpers/toggle.js
import { helper as buildHelper } from '@ember/component/helper';
export function and(params: any[] /*, hash*/) {
return params[0] && params[1];
}
export const helper = buildHelper(and);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:8,代码来源:and.ts
示例7: preventDefault
import { helper as buildHelper } from '@ember/component/helper';
type PositionalArgs = [(...args: any) => void];
export function preventDefault([fn]: PositionalArgs /*, hash*/) {
return (...args: any[]) => {
const firstArg = args[0];
if (firstArg && firstArg.preventDefault) {
firstArg.preventDefault();
}
return fn(...args);
};
}
export const helper = buildHelper(preventDefault);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:17,代码来源:prevent-default.ts
示例8: htmlSafe
import { helper as buildHelper } from '@ember/component/helper';
import { htmlSafe as makeSafe } from '@ember/string';
export function htmlSafe(params: any[] /*, hash*/) {
return makeSafe(params[0]);
}
export const helper = buildHelper(htmlSafe);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:8,代码来源:html-safe.ts
示例9: mult
import { helper as buildHelper } from '@ember/component/helper';
export function mult(params: any[] /*, hash*/) {
return params[0] * params[1];
}
export const helper = buildHelper(mult);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:7,代码来源:mult.ts
示例10: nextIndex
import { helper as buildHelper } from '@ember/component/helper';
import { get, set } from '@ember/object';
import { isPresent } from '@ember/utils';
function nextIndex(length: number, currentIdx: number) {
if (currentIdx === -1 || currentIdx + 1 === length) {
return 0;
}
return currentIdx + 1;
}
type PositionalArguments = [string, any, ...any[]];
export function toggle([prop, obj, ...values]: PositionalArguments) {
return function() {
let currentValue = get(obj, prop);
if (isPresent(values)) {
let currentIdx = values.indexOf(currentValue);
let nextIdx = nextIndex(get(values, 'length'), currentIdx);
return set(obj, prop, values[nextIdx]);
}
return set(obj, prop, !currentValue);
};
}
export const helper = buildHelper(toggle);
开发者ID:NullVoxPopuli,项目名称:emberclear,代码行数:30,代码来源:toggle.ts
注:本文中的@ember/component/helper.helper函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论