我正在尝试修改插件,它是一个日历。当您按下不属于月份的日期(月份的开头和月末)时,它将更改为下个月或上个月。我试图禁用它,我发现要更改代码的哪一部分,但是当我进行更改(或添加console.log
消息)时,执行ionic serve
时没有任何反映。有一件事是,日历是用AngularJS
写的 - 而我正在使用Ionic,它使用Angular 2
。我试图改变的代码部分如下所示:
$scope.select = function (viewDate) {
console.log("in in in select &&&&&&&");
var selectedDate = viewDate.date,
events = viewDate.events,
views = scope.views,
dates,
r;
if (views) {
dates = views[scope.currentViewIndex].dates;
var currentCalendarDate = ctrl.currentCalendarDate;
var currentMonth = currentCalendarDate.getMonth();
var currentYear = currentCalendarDate.getFullYear();
var selectedMonth = selectedDate.getMonth();
var selectedYear = selectedDate.getFullYear();
var direction = 0;
if (currentYear === selectedYear) {
if (currentMonth !== selectedMonth) {
direction = currentMonth < selectedMonth ? 1 : -1;
}
} else {
direction = currentYear < selectedYear ? 1 : -1;
}
ctrl.currentCalendarDate = selectedDate;
if (direction === 0) {
if (ngModelCtrl) {
ngModelCtrl.$setViewValue(selectedDate);
}
var currentViewStartDate = ctrl.range.startTime,
oneDay = 86400000,
selectedDayDifference = Math.floor((selectedDate.getTime() - currentViewStartDate.getTime()) / oneDay);
for (r = 0; r < 42; r += 1) {
dates[r].selected = false;
}
if (selectedDayDifference >= 0 && selectedDayDifference < 42) {
dates[selectedDayDifference].selected = true;
scope.selectedDate = dates[selectedDayDifference];
}
} else {
console.log("is getting here &&^^%%$$");
//ctrl.moveOnSelected = true;
//ctrl.slideView(direction); <----- I AM COMMENTING THIS OUT TO STOP THE SLIDE!!!
}
...
在上面代码块的底部,我做了一个箭头指向我正在评论的两行。我还添加了console.log
语句,一个在函数的开头,一个在中间,并且它们都没有输出到控制台(上面是select
函数,它发生在日期时选择日历)。
插件的代码结构如下:
angular.module("ui.rCalendar.tpls", ["templates/rcalendar/calendar.html","templates/rcalendar/day.html","templates/rcalendar/displayEvent.html","templates/rcalendar/month.html","templates/rcalendar/monthviewDisplayEvent.html","templates/rcalendar/monthviewEventDetail.html","templates/rcalendar/week.html"]);
angular.module('ui.rCalendar', ['ui.rCalendar.tpls'])
.constant('calendarConfig', {
formatDay: 'dd',
formatDayHeader: 'EEE',
formatDayTitle: 'MMMM dd, yyyy',
formatWeekTitle: 'MMMM yyyy, Week w',
formatMonthTitle: 'MMMM yyyy',
formatWeekViewDayHeader: 'EEE d',
formatHourColumn: 'ha',
calendarMode: 'month',
showEventDetail: true,
startingDayMonth: 0,
startingDayWeek: 0,
allDayLabel: 'all day',
noEventsLabel: 'No Events',
eventSource: null,
queryMode: 'local',
step: 60,
autoSelect: true,
monthviewDisplayEventTemplateUrl: 'templates/rcalendar/monthviewDisplayEvent.html',
monthviewEventDetailTemplateUrl: 'templates/rcalendar/monthviewEventDetail.html',
weekviewAllDayEventTemplateUrl: 'templates/rcalendar/displayEvent.html',
weekviewNormalEventTemplateUrl: 'templates/rcalendar/displayEvent.html',
dayviewAllDayEventTemplateUrl: 'templates/rcalendar/displayEvent.html',
dayviewNormalEventTemplateUrl: 'templates/rcalendar/displayEvent.html'
})
.controller('ui.rCalendar.CalendarController'
...
.directive('monthview', ['dateFilter', function (dateFilter) {
THIS IS WHERE THE SELECT FUNCTION IS
...
这是angularjs
应用中的Ionic
插件,请记住它是基于Angular 2
而不是angularjs
构建的。我不确定插件javascript文件的加载位置。
答案 0 :(得分:0)
我正在查找错误的包文件夹,我没有意识到我已经安装了打字稿版本。