Keep track of all clicks on page


#1

Hello All,

I have created simple page which contains check boxes. On this page user can check and uncheck boxes multiple times. I want to keep track of all these events? How Can I do that?

here is my code.

app.js

var pmApp = angular.module('pmApp', ['ionic']);

pmApp.controller('CheckboxController', function($scope) {
  $scope.devList = [
    { text: "Device & app history", details : "Allows the app to view one or more of: information about activity on the device, which apps are running, browsing history and bookmarks" ,checked: true },
    { text: "Identity", details: "Uses one or more of: accounts on the device, profile data", checked: false },
    { text: "Calendar", details: "Uses calendar information", checked: false },
    { text: "Contact", details: "Uses contact information", checked: false },
    { text: "Location", details: "Uses the device's location", checked: false },
    { text: "SMS", details: "Uses one or more of: SMS, MMS. Charges may apply.", checked: false }
  ];

  $scope.selection=[];
  // toggle selection for a given employee by name
  $scope.toggleSelection = function toggleSelection(item) {
     var idx = $scope.selection.indexOf(item);

     // is currently selected
     if (idx > -1) {
       $scope.selection.splice(idx, 1);
     }

     // is newly selected
     else {
       $scope.selection.push(item);
     }
   };

});

index.html

      <div class="list" ng-controller="CheckboxController">
        <ion-checkbox ng-repeat="item in devList"
                      ng-model="item.checked" 
                      ng-checked="selection.indexOf(item) > -1"
                      ng-click="toggleSelection(item)"
                      >
            {{ item.text }}
            <h3 class="item-text-wrap"> {{ item.details }}</h3>
        </ion-checkbox>
<div class="item">
          <pre ng-bind="selection | json"></pre> 
</div>
      </div>

Thanks in advance, any help would be appreciated.

Regards