Number of notifications in local notification probelm


#1

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.


#2

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;
    });

#3

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


#4

I would recommend you to check out the following links: