本文整理汇总了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 });
});
});
}
}