【发布时间】:2015-06-26 20:42:56
【问题描述】:
我创建了包含复选框的简单页面。在此页面上,用户可以多次选中和取消选中复选框。我想跟踪所有这些事件?我该怎么做?
这是我的代码。
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>
在此先感谢,任何帮助将不胜感激。
问候
【问题讨论】:
-
您希望在哪里跟踪触发的事件以及您希望准确跟踪什么?
-
@mxa055 我想跟踪复选框勾选或取消勾选鼠标悬停事件和用户的按钮点击。我想用时间戳来跟踪所有触发事件。我想将这些跟踪数据保留在服务器端。如何将数据放在服务器端? Mongo DB 还是简单的 SQL?
标签: angularjs cordova ionic-framework angularjs-directive