Number of notifications in local notification probelm

Hello dear
I have below code to get number of notifications in local notifications

LocalNotifications.getAllIds(function(ids) {
           this.hasids=ids.length;
        });

but this.hasids is not showing in the html file. code in html file is as below

{{hasids}}

What is the problem. But When I use alert(ids.length); It is showing number of alarm correctly. Plz help.

You have to use an arrow function in order to capture the this value of the enclosing context, so that your code works as expected:

    LocalNotifications.getAllIds((ids) => {
        this.hasids = ids.length;
    });
1 Like

Thank you so much. Solved. Can u suggest me how can learn this types of tricks ? Your solution helped me so much.

I would recommend you to check out the following links:

1 Like