dimanche 3 mai 2020

Calling onload checkbox event

I am using angular to remove past events from the list. It works as expected when the checkbox is checked or unchecked.

I wanted to trigger pastEvents method onpage load so that based on the checkbox value, it will remove or will not remove events from the list.

I tried calling the method like this

pastEvents(); but it did not work.

Any help or suggestion would be appreciated.

Below is my code.

     <div>
         <input value="" type="checkbox" ng-click="pastEvents($event)" />
         <label for="checkbox">Past Events</label>
     </div>


  $scope.pastEvents = function pastEvents(event) {
            $scope.filterPastEvents = function (el) {
                if (!event.target.checked) {
                    return true;
                }
                if (el.IsPastEvent === "past") {
                    return false;
                }
                return true;
            };
        };

Thanks in advance




Aucun commentaire:

Enregistrer un commentaire