I have been working on developing an Ionic application with angular.js and I am almost done, but I have encountered a minor issue.
Inside my templates/menu.html
file, I have the following code:
<ion-item nav-clear menu-close ng-click="filterByPeriod(weekBegin, currentDate)">Filter </ion-item>
and in my controller.js file:
.controller('Home', ['$scope', '$ionicModal', '$cordovaGeolocation', function($scope, $ionicModal, $cordovaGeolocation) {
App = {
init: function() {
setTimeout(function(){
$scope.map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}, 200);
},
};
$scope.addMarkersToMap = function(reports, map) {
var newCenter = new google.maps.LatLng(reports[0].latitude, reports[0].longitude);
map.setCenter(newCenter);
map.setZoom(12);
}
$scope.filterByPeriod = function(beginDate, endDate) {
var cityId = window.localStorage.getItem('cityId');
serviceReports.getDenunciasFromPeriod(cityId, beginDate, endDate)
.success(function(reports){
$scope.addMarkersToMap(reports.dados, $scope.map);
});
}
App.init();
}]);
I have tried using `$scope.apply(function(){}) to encapsulate the method, but I am still getting the following error:
Does anyone have any suggestions on how to resolve this issue?