當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。