On page load i have a controller that calls a service and then binds the returned data to some $scope.objects:
app.controller("MainController", function($scope, $http, serviceGetData) {
serviceGetData.getData(function(data) {
$scope.LoginCount = data.LoginCount;
$scope.ProductInfo = data.ProductInfo;
$scope.ProfileInfo = data.ProfileInfo;
// Delayed binding
$scope.OrderHistory = { History: [] };
}
$scope.populateModel = function(model, values) {
var isArray = $.isArray(values);
$.each(values, function(key, value) {
if (isArray) {
key = this.key;
value = this.value;
}
if (model[key] !== value) {
model[key] = value;
}
});
};
}
And in my HTML, i try to bind $scope.OrderHistory by:
<h1><a href="#" ng-click="populateModel(OrderHistory , { History: OrderEntries })" >View order details</a></h1>
This is fine when viewing on laptops/desktops, but not working in tablet and mobile devices e.g. iphone/ipad
Try to add the ngTouch. From documentation:
I had the same problem.
I tried adding the
ngTouch
library and dependency, but was still having a problem.My static
<div>
elements which contained anng-click
worked fine, but the div's which were created dynamically (in anng-repeat
on the same webpage) which contained anng-click
didn't work. Tapping on them just didn't do anything.This happened on my iPhone 6, my iPad and in Google Chrome when I asked to view my webpage on any of the device types. When I viewed the same webpage in IE or regular Chrome, all of the
ng-click
s worked fine.The solution was to use the
ngMobileClick
directive described here and changing myng-click
's tong-mobile-click
.After doing that, my dynamically created click events did get triggered normally when I tapped on them on a device.
Very odd.
Had a similar issue where the ng-click inside of a ng-repeat would not trigger. I fixed this by adding $event.stopPropagation()
Ex: