I am trying to make a calendar where I will get the information in a rest request in angularjs. What I want to create is a calendar where you can register your events. With the json date attribute it inserts this event and registers an icon on that day.
My error is as you can see in the image it will fetch an array and insert it into the fields all and not only on the day it was registered in json. My function repeats 42 times which is the number of squares in the calendar. Anyone know where the error in my approach is I'm not realizing.
Image
Json
{"data":[
{"title":"John",
"start":"2016-10-22"
}, {
"title":"João",
"start":"2016-10-25"
}
]}
controller
$scope.setDayContent = function(date) {
return $http ({
method : "GET",
url : "app/components/home/controller/test_calendar.json"
}).then(function mySucces(response) {
console.log(response.data.data[1]);
}, function myError(response) {
$scope.valor = response.statusText;
});
html
<calendar-md flex layout layout-fill
calendar-direction="direction"
on-prev-month="prevMonth"
on-next-month="nextMonth"
on-day-click="dayClick"
ng-model='selectedDate'
week-starts-on="firstDayOfWeek"
tooltips="tooltips"
day-format="dayFormat"
day-content="setDayContent"
></calendar-md>
version 2:
$scope.loadData = function(){
return $http ({
method : "GET",
url : "app/components/home/controller/test_calendar.json"
}).then(function mySucces(response) {
$scope.jsonData = response.data.data;
}, function myError(response) {
$scope.valor = response.statusText;
});
}
$scope.setDayContent = function(date, content) {
//check if $scope.jsonData contains date parameter
// return title
};