Updating Badge Values

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
phill_jones
Posts: 7
Joined: 12 Feb 2017, 23:56

12 Nov 2017, 22:35

(this was originally incorrectly posted in the Omega section)

Hi,

I am trying to dynamically update the badge value after the initial render, is there a simple way of doing this that I am missing?

For example

badgeValue: number = 10;

...
items: [
{ label: 'All Incoming', icon: 'im-icon im-icon-phone-incoming', badge:badgeValue:number , routerLink: ['/calls/all'] },
...

10 will be correctly displayed as badge number.

However, updating badgeValue = 12 will not reset the badge value displaying the rendered menu. What am I missing?

Many thanks.

Phil

merve7
Posts: 861
Joined: 12 Sep 2017, 10:44

13 Nov 2017, 12:10

Can you try this?

Code: Select all

...
badgeValue : number;
items: [
{ label: 'All Incoming', icon: 'im-icon im-icon-phone-incoming', badge:10 , routerLink: ['/calls/all'] },
...

Code: Select all

this.items[0].badge = this.badgeValue;

phill_jones
Posts: 7
Joined: 12 Feb 2017, 23:56

13 Nov 2017, 20:17

Thanks for the reply.

Yes that would definitely work and is how I have since implemented it

Code: Select all

for (var i in this.model) {
             if ( this.model[i].label == "Call Activity") {
                for (var n in this.model[i].items) {
                    switch (this.model[i].items[n].label) {
                        case "All Incoming":
                            this.model[i].items[n].badge = data.total;
                            break;
                        case "Voicemail":
                            this.model[i].items[n].badge = data.vm;
                            break;
                         default:
                            break;
                    }
                }
                break; //Stop this loop, we found it!
             }
        }
I guess I was just wondering if there were an easier way to bind to a variable / or a best practice etc.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

30 Nov 2017, 13:38

We can't think of another way at the moment.

Post Reply

Return to “Avalon - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest