How to convert the Jquery Implemenation to angular 6
up vote
0
down vote
favorite
I have a using https://github.com/nekken/ng2-fullcalendar/ below library for my calander, But there have limited options in this library, so i have used full calender api for extend to fullfill business requriements.
So here is the function Viewrender implementation function to disable previous and next months buttons when crossed future one months and previous one month.
Eg)button should be disable when current month is Nov 2018 - if user clicks on JAn 2019 next button should disable and user choose Sep 2018 previous button should disable.
I have written a logic in jquery inside angualr function , anyone convert this into angular 6 way.
onViewRender(view, element)
// alert(view.intervalStart);
// alert(view.intervalEnd);
// alert(view.start);
// alert(view.end);
// alert(view.title);
// console.log(view.intervalStart);
// console.log(view.intervalEnd);
var now = new Date();
var end = new Date();
end.setMonth(now.getMonth() + 1);
console.log( view.start.format('MM'));//11
console.log(view.start.format('YYYY'));//2018
var cal_date_string = view.start.format('MM')+'/'+view.start.format('YYYY');
var cur_date_string = now.getMonth()+'/'+now.getFullYear();
var end_date_string = end.getMonth()+'/'+end.getFullYear();
if(cal_date_string == cur_date_string) jQuery('.fc-prev-button').addClass("fc-state-disabled");
else jQuery('.fc-prev-button').removeClass("fc-state-disabled");
if(end_date_string == cal_date_string) jQuery('.fc-next-button').addClass("fc-state-disabled");
else jQuery('.fc-next-button').removeClass("fc-state-disabled");
Stackblitz Demo:
demo
angular fullcalendar angular6 angular-calendar
add a comment |
up vote
0
down vote
favorite
I have a using https://github.com/nekken/ng2-fullcalendar/ below library for my calander, But there have limited options in this library, so i have used full calender api for extend to fullfill business requriements.
So here is the function Viewrender implementation function to disable previous and next months buttons when crossed future one months and previous one month.
Eg)button should be disable when current month is Nov 2018 - if user clicks on JAn 2019 next button should disable and user choose Sep 2018 previous button should disable.
I have written a logic in jquery inside angualr function , anyone convert this into angular 6 way.
onViewRender(view, element)
// alert(view.intervalStart);
// alert(view.intervalEnd);
// alert(view.start);
// alert(view.end);
// alert(view.title);
// console.log(view.intervalStart);
// console.log(view.intervalEnd);
var now = new Date();
var end = new Date();
end.setMonth(now.getMonth() + 1);
console.log( view.start.format('MM'));//11
console.log(view.start.format('YYYY'));//2018
var cal_date_string = view.start.format('MM')+'/'+view.start.format('YYYY');
var cur_date_string = now.getMonth()+'/'+now.getFullYear();
var end_date_string = end.getMonth()+'/'+end.getFullYear();
if(cal_date_string == cur_date_string) jQuery('.fc-prev-button').addClass("fc-state-disabled");
else jQuery('.fc-prev-button').removeClass("fc-state-disabled");
if(end_date_string == cal_date_string) jQuery('.fc-next-button').addClass("fc-state-disabled");
else jQuery('.fc-next-button').removeClass("fc-state-disabled");
Stackblitz Demo:
demo
angular fullcalendar angular6 angular-calendar
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a using https://github.com/nekken/ng2-fullcalendar/ below library for my calander, But there have limited options in this library, so i have used full calender api for extend to fullfill business requriements.
So here is the function Viewrender implementation function to disable previous and next months buttons when crossed future one months and previous one month.
Eg)button should be disable when current month is Nov 2018 - if user clicks on JAn 2019 next button should disable and user choose Sep 2018 previous button should disable.
I have written a logic in jquery inside angualr function , anyone convert this into angular 6 way.
onViewRender(view, element)
// alert(view.intervalStart);
// alert(view.intervalEnd);
// alert(view.start);
// alert(view.end);
// alert(view.title);
// console.log(view.intervalStart);
// console.log(view.intervalEnd);
var now = new Date();
var end = new Date();
end.setMonth(now.getMonth() + 1);
console.log( view.start.format('MM'));//11
console.log(view.start.format('YYYY'));//2018
var cal_date_string = view.start.format('MM')+'/'+view.start.format('YYYY');
var cur_date_string = now.getMonth()+'/'+now.getFullYear();
var end_date_string = end.getMonth()+'/'+end.getFullYear();
if(cal_date_string == cur_date_string) jQuery('.fc-prev-button').addClass("fc-state-disabled");
else jQuery('.fc-prev-button').removeClass("fc-state-disabled");
if(end_date_string == cal_date_string) jQuery('.fc-next-button').addClass("fc-state-disabled");
else jQuery('.fc-next-button').removeClass("fc-state-disabled");
Stackblitz Demo:
demo
angular fullcalendar angular6 angular-calendar
I have a using https://github.com/nekken/ng2-fullcalendar/ below library for my calander, But there have limited options in this library, so i have used full calender api for extend to fullfill business requriements.
So here is the function Viewrender implementation function to disable previous and next months buttons when crossed future one months and previous one month.
Eg)button should be disable when current month is Nov 2018 - if user clicks on JAn 2019 next button should disable and user choose Sep 2018 previous button should disable.
I have written a logic in jquery inside angualr function , anyone convert this into angular 6 way.
onViewRender(view, element)
// alert(view.intervalStart);
// alert(view.intervalEnd);
// alert(view.start);
// alert(view.end);
// alert(view.title);
// console.log(view.intervalStart);
// console.log(view.intervalEnd);
var now = new Date();
var end = new Date();
end.setMonth(now.getMonth() + 1);
console.log( view.start.format('MM'));//11
console.log(view.start.format('YYYY'));//2018
var cal_date_string = view.start.format('MM')+'/'+view.start.format('YYYY');
var cur_date_string = now.getMonth()+'/'+now.getFullYear();
var end_date_string = end.getMonth()+'/'+end.getFullYear();
if(cal_date_string == cur_date_string) jQuery('.fc-prev-button').addClass("fc-state-disabled");
else jQuery('.fc-prev-button').removeClass("fc-state-disabled");
if(end_date_string == cal_date_string) jQuery('.fc-next-button').addClass("fc-state-disabled");
else jQuery('.fc-next-button').removeClass("fc-state-disabled");
Stackblitz Demo:
demo
angular fullcalendar angular6 angular-calendar
angular fullcalendar angular6 angular-calendar
edited Nov 10 at 13:38
asked Nov 10 at 13:32
Mohamed Sahir
54741225
54741225
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The easiest way is to use NgClass.
You create a boolean
inside your controller ts code isPrevButtonEnabled
and isNextButtonEnabled
(class members).
In your component, you put inside your .fc-prev-button
element:
[ngClass]=" 'fc-state-disabled': !isPrevButtonEnabled "
same thing for your Next button.
In your ts code, you simply use:
isPrevButtonEnabled = cal_date_string !== cur_date_string;
And same thing for NextButton.
Edit:
If you can't modify the component code, just use the following to retrieve the DOM element: document.getElementsByClassName("fc-prev-button");
.
But beware, it might be false if the elements are not yet created in the DOM. Use in OnAfterViewInit
and you should be fine.
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The easiest way is to use NgClass.
You create a boolean
inside your controller ts code isPrevButtonEnabled
and isNextButtonEnabled
(class members).
In your component, you put inside your .fc-prev-button
element:
[ngClass]=" 'fc-state-disabled': !isPrevButtonEnabled "
same thing for your Next button.
In your ts code, you simply use:
isPrevButtonEnabled = cal_date_string !== cur_date_string;
And same thing for NextButton.
Edit:
If you can't modify the component code, just use the following to retrieve the DOM element: document.getElementsByClassName("fc-prev-button");
.
But beware, it might be false if the elements are not yet created in the DOM. Use in OnAfterViewInit
and you should be fine.
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
add a comment |
up vote
0
down vote
The easiest way is to use NgClass.
You create a boolean
inside your controller ts code isPrevButtonEnabled
and isNextButtonEnabled
(class members).
In your component, you put inside your .fc-prev-button
element:
[ngClass]=" 'fc-state-disabled': !isPrevButtonEnabled "
same thing for your Next button.
In your ts code, you simply use:
isPrevButtonEnabled = cal_date_string !== cur_date_string;
And same thing for NextButton.
Edit:
If you can't modify the component code, just use the following to retrieve the DOM element: document.getElementsByClassName("fc-prev-button");
.
But beware, it might be false if the elements are not yet created in the DOM. Use in OnAfterViewInit
and you should be fine.
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
add a comment |
up vote
0
down vote
up vote
0
down vote
The easiest way is to use NgClass.
You create a boolean
inside your controller ts code isPrevButtonEnabled
and isNextButtonEnabled
(class members).
In your component, you put inside your .fc-prev-button
element:
[ngClass]=" 'fc-state-disabled': !isPrevButtonEnabled "
same thing for your Next button.
In your ts code, you simply use:
isPrevButtonEnabled = cal_date_string !== cur_date_string;
And same thing for NextButton.
Edit:
If you can't modify the component code, just use the following to retrieve the DOM element: document.getElementsByClassName("fc-prev-button");
.
But beware, it might be false if the elements are not yet created in the DOM. Use in OnAfterViewInit
and you should be fine.
The easiest way is to use NgClass.
You create a boolean
inside your controller ts code isPrevButtonEnabled
and isNextButtonEnabled
(class members).
In your component, you put inside your .fc-prev-button
element:
[ngClass]=" 'fc-state-disabled': !isPrevButtonEnabled "
same thing for your Next button.
In your ts code, you simply use:
isPrevButtonEnabled = cal_date_string !== cur_date_string;
And same thing for NextButton.
Edit:
If you can't modify the component code, just use the following to retrieve the DOM element: document.getElementsByClassName("fc-prev-button");
.
But beware, it might be false if the elements are not yet created in the DOM. Use in OnAfterViewInit
and you should be fine.
edited Nov 10 at 14:01
answered Nov 10 at 13:41
Mic
1,89111431
1,89111431
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
add a comment |
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
can you able to do it in the demo file, because the button builtin there framework.stackblitz.com/edit/github-inz3zg-gfbsdz?file=src/app/…
– Mohamed Sahir
Nov 10 at 13:45
Edited my answer
– Mic
Nov 10 at 14:01
Edited my answer
– Mic
Nov 10 at 14:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239471%2fhow-to-convert-the-jquery-implemenation-to-angular-6%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown