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


TypeScript CoreTextUtilsProvider.formatText方法代码示例

本文整理汇总了TypeScript中@providers/utils/text.CoreTextUtilsProvider.formatText方法的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreTextUtilsProvider.formatText方法的具体用法?TypeScript CoreTextUtilsProvider.formatText怎么用?TypeScript CoreTextUtilsProvider.formatText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@providers/utils/text.CoreTextUtilsProvider的用法示例。


在下文中一共展示了CoreTextUtilsProvider.formatText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 sites.forEach((site: any) => {
     // Format the site name.
     promises.push(this.textUtils.formatText(site.siteName, true, true).catch(() => {
         return site.siteName;
     }).then((formatted) => {
         site.fullNameAndSiteName = this.translate.instant('core.fullnameandsitename',
             { fullname: site.fullName, sitename: formatted });
     }));
 });
开发者ID:jleyva,项目名称:moodlemobile2,代码行数:9,代码来源:site-picker.ts

示例2: showStatus

    /**
     * Set image and description to show as completion icon.
     */
    protected showStatus(): void {
        const moduleName = this.moduleName || '';
        let langKey,
            image;

        if (this.completion.tracking === 1 && this.completion.state === 0) {
            image = 'completion-manual-n';
            langKey = 'core.completion-alt-manual-n';
        } else if (this.completion.tracking === 1 && this.completion.state === 1) {
            image = 'completion-manual-y';
            langKey = 'core.completion-alt-manual-y';
        } else if (this.completion.tracking === 2 && this.completion.state === 0) {
            image = 'completion-auto-n';
            langKey = 'core.completion-alt-auto-n';
        } else if (this.completion.tracking === 2 && this.completion.state === 1) {
            image = 'completion-auto-y';
            langKey = 'core.completion-alt-auto-y';
        } else if (this.completion.tracking === 2 && this.completion.state === 2) {
            image = 'completion-auto-pass';
            langKey = 'core.completion-alt-auto-pass';
        } else if (this.completion.tracking === 2 && this.completion.state === 3) {
            image = 'completion-auto-fail';
            langKey = 'core.completion-alt-auto-fail';
        }

        if (image) {
            if (this.completion.overrideby > 0) {
                image += '-override';
            }
            this.completionImage = 'assets/img/completion/' + image + '.svg';
        }

        if (moduleName) {
            this.textUtils.formatText(moduleName, true, true, 50).then((modNameFormatted) => {
                let promise;

                if (this.completion.overrideby > 0) {
                    langKey += '-override';

                    promise = this.userProvider.getProfile(this.completion.overrideby, this.completion.courseId, true).then(
                        (profile) => {
                            return {
                                overrideuser: profile.fullname,
                                modname: modNameFormatted
                            };
                        });
                } else {
                    promise = Promise.resolve(modNameFormatted);
                }

                return promise.then((translateParams) => {
                    this.completionDescription = this.translate.instant(langKey, { $a: translateParams });
                });
            });
        }
    }
开发者ID:jleyva,项目名称:moodlemobile2,代码行数:59,代码来源:module-completion.ts


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