使用翻译服务时我有一个非常奇怪的行为。我这样配置翻译器:
export class AppComponent implements OnInit {
constructor(
private translateService: TranslateService,
angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics,
angulartics2: Angulartics2,
router: Router,
private googleAnalyticsService: GoogleAnalyticsService,
) {
translateService.setDefaultLang('en');
translateService.use('en');
}
Run Code Online (Sandbox Code Playgroud)
和我的 HomeComponent :
export class HomePageComponent implements OnInit {
constructor(
private seoService: SeoService,
private translateService: TranslateService
) {
}
ngOnInit() {
this.addPageMeta();
console.log('Add Page Meta');
}
addPageMeta() {
const title = this.translateService.instant('seo.home.title');
const meta: SeoMeta = {
url : '/home',
title: title,
description: this.translateService.instant('seo.home.description'),
};
this.seoService.setPageTitle(title);
this.seoService.addMeta(meta);
}
}
Run Code Online (Sandbox Code Playgroud)
核心.module.ts:
TranslateModule.forRoot({
loader: {
provide: TranslateLoader, …Run Code Online (Sandbox Code Playgroud) 我有这个文字:
Ch d\`Arnb
Run Code Online (Sandbox Code Playgroud)
现在我想\从字符串中删除所有字符串.我尝试了很多解决方案,其中之一:{{ item|replace({'\/': ''}) }}.但是成功了.你能帮我吗 ?Thx提前和抱歉我的英语.
我有这个数组:
this.menuItems = [
{
category: 'category 4',
items: [
{
type: 'link',
icon: '',
},
{
type: 'link',
icon: '',
},
]
},
{
category: 'category 1',
items: [
{
type: 'text',
icon: 'pencil'
},
{
type: 'checkbox',
icon: 'pencil'
},
]
},
Run Code Online (Sandbox Code Playgroud)
我想从menuItemstype = 中删除对象checkbox。我试过这样:
this.menuItems.forEach(category => {
category.items.forEach((item, index) => {
if (item.type === 'checkbox') {
category.splice(index, 1);
}
});
});
Run Code Online (Sandbox Code Playgroud)
但不工作。你能帮我一些建议吗?提前谢谢