本文整理匯總了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 });
}));
});
示例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 });
});
});
}
}