0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.