Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

444
Views
Update the string value in the object based on the parameter - Typescript

I have exported an object in a separate ts file and I would like that to be parameterized

export const customer = {
  comment: 'Wow, this is great because {{username}} is doing what we needed' 
};

Then in another ts file, I get this constant but I want to pass the value of username

import * as customerConstants from 'constants';
export class CustomerComponent implements OnInit{
 username ='learn' 
 customerData = customerConstants.customer ;

  ngOnInit(): void {
    this.customerData.comment = customerData + username;
  }

I want to put learn in place of username in the customer const. Is it possible?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since customer.comment is string you could use replace() to replace '{{username}}' with username variable value.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!