search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to call custom function in onTimeRangeSelected

Asked by Hiren
4 years ago.

In angular 6 i have many custom function so can call that function after add new task with this method onTimeRangeSelected. Example Like Below :

onTimeRangeSelected: function (args) {
var dp = this;
DayPilot.Modal.prompt("Create a new task:", "").then(function(modal) {
if (!modal.result) { return; } DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result

Answer posted by Dan Letecky [DayPilot]
4 years ago.

When you use the JavaScript declaration style you won't be able to access the component object as "this":

onTimeRangeSelected: function(args) {
  // ...
  this.myFunction();  // won't work

It's necessary to use an arrow function - ES6/TypeScript syntax (

onTimeRangeSelected: args => {
  // ...
  this.myFunction();  // works as expected
Comment posted by Hiren
4 years ago.

i have resolve this using below example :

DayPilot.Modal.prompt("Create a new task:", "",this).then(function(modal) {
if (!modal.result) { return; }

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.