Я очень новичок в угловой JS. Наконец я нашел хороший календарь, который идет с событием, которое создает случайные события.
Теперь я хочу знать, как добавить одно событие.
Это JS:
angular.module('downtimeCalendarApp', ['ui.rCalendar']);
angular.module('downtimeCalendarApp').controller ('CalendarCtrl', ['$scope', function ($scope) {
'use strict';
$scope.changeMode = function (mode) {
$scope.mode = mode;
};
$scope.today = function () {
$scope.currentDate = new Date();
};
$scope.isToday = function () {
var today = new Date(),
currentCalendarDate = new Date($scope.currentDate);
today.setHours(0, 0, 0, 0);
currentCalendarDate.setHours(0, 0, 0, 0);
return today.getTime() === currentCalendarDate.getTime();
};
$scope.loadEvents = function () {
$scope.eventSource = createRandomEvents();
};
$scope.onEventSelected = function (event) {
$scope.event = event;
};
$scope.onTimeSelected = function (selectedTime, events) {
console.log('Selected time: ' + selectedTime + ' hasEvents: ' + (events !== undefined && events.length !== 0));
};
function createRandomEvents() {
var events = [];
for (var i = 0; i < 50; i += 1) {
var date = new Date();
var eventType = Math.floor(Math.random() * 2);
var startDay = Math.floor(Math.random() * 90) - 45;
var endDay = Math.floor(Math.random() * 2) + startDay;
var startTime;
var endTime;
if (eventType === 0) {
startTime = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + startDay));
if (endDay === startDay) {
endDay += 1;
}
endTime = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate() + endDay));
events.push({
title: 'Planned Maintenance: Mercedes PRO connect Store',
startTime: startTime,
endTime: endTime,
allDay: true
});
} else {
var startMinute = Math.floor(Math.random() * 24 * 60);
var endMinute = Math.floor(Math.random() * 180) + startMinute;
startTime = new Date(date.getFullYear(), date.getMonth(), date.getDate() + startDay, 0, date.getMinutes() + startMinute);
endTime = new Date(date.getFullYear(), date.getMonth(), date.getDate() + endDay, 0, date.getMinutes() + endMinute);
events.push({
title: 'Downtime: #48834734994 Mercedes me connect',
startTime: startTime,
endTime: endTime,
description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum',
allDay: false
});
}
}
return events;
}
Итак, я хочу удалить случайную часть события и создать отдельные события в этом формате, как я делал для своих билетов в другом JS.
$scope.tickets = [
{
'startTime: 'xxxxx',
'endTime': 'xxxxx',
'title': 'xxxxx',
and more...
}
];
Может кто-нибудь мне помочь и подсказать, где это можно изменить в скрипте календаря выше. Или веди меня шаг за шагом
Спасибо!