1

How to use a controller and assign badge number to a ion-tab using scope variable from the controller ? I'm getting error when I tried this-

<ion-tab title="Home" badge={{homeBadgeCount}} ...

Syntax Error: Token '{' invalid key at column 2 of the expression angular

Please help...

Tushar
  • 3,022
  • 2
  • 26
  • 26

2 Answers2

0

Just figured out that I don't need to use the {{}} expression. Without that it works !!!

<ion-tab title="Home" badge=homeBadgeCount ...
Tushar
  • 3,022
  • 2
  • 26
  • 26
0

As you can see, you can do it like badge=homeBadgeCount but that is not the best solution.

See w3schools / html attributes in section "We Suggest: Always Quote Attribute Values" to know why your solution works but is not the best practice.

Moreover, to know why your first try didn't work; I advice you to read these pages:

tl;dr write badge="homeBadgeCount" instead !

Community
  • 1
  • 1
Toldy
  • 1,241
  • 1
  • 14
  • 27