1

After login i want show a toaster as Welcome to logged username. enter image description here

Shashikant Devani
  • 2,298
  • 1
  • 12
  • 25
  • Possible duplicate of [How can I do string interpolation in JavaScript?](https://stackoverflow.com/q/1408289) – Makyen Sep 05 '18 at 09:26
  • Possible duplicate of [How can I do string interpolation in JavaScript?](https://stackoverflow.com/questions/1408289/how-can-i-do-string-interpolation-in-javascript) – Machavity Sep 06 '18 at 13:36

2 Answers2

0
this.toastr.success('Welcome to '+authenticUser.user.firstName,'Success')

or

this.toastr.success(`Welcome to ${authenticUser.user.firstName}`,'Success');
Krishna Rathore
  • 9,389
  • 5
  • 24
  • 48
0

In Angular or any programming lanuage, it's advised to use the back-tick for string concatenation.

this.toastr.success(`Welcome to ${authenticUser.user.firstName}`,'Success');
Suresh Kumar Ariya
  • 9,516
  • 1
  • 18
  • 27
  • 1
    "any programming language"... ahhh, No. Even if you are really meaning JavaScript, or some library on top of JavaScript, then you still need to consider what environments (e.g. browsers) [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Browser_compatibility) are available in (e.g. not in IE). Obviously, that's not a concern if you are cross-compiling into compatible JavaScript. – Makyen Sep 05 '18 at 09:01
  • Yes agree. we have polyfills for IE too. Also angular CLI will convert to ES5 while performing build. – Suresh Kumar Ariya Sep 05 '18 at 09:05
  • Well, I was really trying to point out that saying "any programming language" is *way* to broad. Are you *really* trying to say that you should use back-ticks in C, C++, Java, Forth, Ada, Prolog, Pascal, FORTRAN 77, etc.? – Makyen Sep 05 '18 at 09:12
  • Ok, Let me correct it. It should be used in JS Programming. – Suresh Kumar Ariya Sep 05 '18 at 09:13