Skip to content

[BUG] Unable to access translation file value (ngx-translate feature) in typescript file (app.component.ts) #2992

@dbhattacharya7790

Description

@dbhattacharya7790

Current Behavior:

import { Component, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';

@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})

export class AppComponent implements OnInit {

constructor(private translate: TranslateService) {
translate.setDefaultLang('en');
translate.use('en');
}
columnConfigs1 = [
{
"columnName": {{'wlcmMsg' | translate}}, // Unable to access translation file values here
"columnInternalName": "name",
"type": "String",
"autoGroupColumnDef": true,
"filter": true,
"pinned": "left"
}
]
}

I am unable to fetch translation file values as shown above in bold. Can anyone suggest how to sort out this issue ?
What would be my approach to achieve the above use case ?

Expected Behavior:

Referring to the above code it should be able access translation file values in type script in the below location as shown:

.......
.......
columnConfigs1 = [
{
"columnName": {{'wlcmMsg' | translate}},
"columnInternalName": "name",
"type": "String",
"autoGroupColumnDef": true,
"filter": true,
"pinned": "left"
}
]
.......

Environment:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions