Using ${{}} now breaks in 3.9.2


#1

If I try to put a dollar sign $ in front of {{somevar}} like this:
${{somevar}}
I get error:
somevar is not defined

Putting a space in between is fine though $ {{somevar}}

This was not a problem prior to 3.9.2

I know I can likely use something like a currencyPipe but is this an error - or just the way things will be for now on?


#2

have you define somevar in your .ts file ?


#3

Yes, as mentioned:
Putting a space in between is fine though $ {{somevar}}
This is new since 3.9.2 and worked previously.

Try it!


#4

Temp fix would be: {{ "$" + somevar }} in case anyone doesn’t realize how simple it is :slight_smile:


#5

Ya, well, in case anyone doesn’t know how simple it is to read the original post:

I know I can likely use something like a currencyPipe but is this an error - or just the way things will be for now on?

I was trying to find out if this is an error/bug or the way things are from here on out with Angular.

Another fix is to use the currencyPipe so the currency can be altered.

Thanks for supplying your fix though.


#6

A currency pipe and what I suggested are still quite different fix, some people might come here and have no idea how pipes work in the slightest. It wasn’t directed at you, but anyone who will stumble upon this thread.


#7

No worries but my point is that this thread is not intended to find a Fix but to determine if the problem is a problem at all or just part of the evolution of Angular.
Not much chance of that now. Not a biggie though.


#8

Are you using template file or writing directly in the .ts file?


#9

Template file.
Give it a whirl, I’d like to see if anyone has this issue. More curiosity than anything now.
Thanks.


#10

Same issue here. I have a feeling it’s related to interpolation in typescript, and the order of operations got messed up somewhere. Not sure where the root of the issue is; ionic, angular, webpack …

  • Adding const somevar = "test"; outside the class in the respective .ts file (or probably any .ts file) gets rid of the error, but shows [object Object]
  • Changing ${{somevar}} to ${somevar} then prints the constant properly

Haven’t been able to find anyone else mentioning it. Also, I found out you can just escape the $ and it works too: \${{somevar}}.


#11

Hey Thanks mich356c,
In-depth response.

This actually caused me to make some positive changes, so be it a bug or not - it turns out for the better.
Cheers


#12

It works perfectly fine in a pure Angular 5 project, which leads me to believe it is Ionic related, but does seem a bit odd if that’s the case. Would you be able to create an issue on https://github.com/ionic-team/ionic/issues and link this post and the issue back in here? I can’t from my current machine, will do later if no one else has by then :slight_smile:


#13

#14

You could always use the Entity Number encoding for the dollar sign which is: $