-1

Following is code for an Angular project service:

@Injectable()
export class FetchDataService {
  fetch(link){
    console.log('this is a ${link}');
  }
}

I'm calling this method in the component passing a string as an arguement.

Console Output: the link is ${link}

1

2 Answers 2

6

Try with backticks like so

@Injectable()
export class FetchDataService {
  fetch(link){
    console.log(`this is a ${link}`);
  }
}

It's called template literal and you can find more info here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

0
0

You can to use following:

console.log('this is a' + link);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.