0

I am trying to learn js.When I execute the below code for first time I am not seeing any error.When I execute second time I am getting the below error.

Uncaught TypeError: Cannot read property 'element' of undefined

Error is pointing to this line:

 alert("that.currentPLAYr.element[0].id--->" + that.currentPLAYr.element[0].id);

My code:

zone.js: 140 Uncaught TypeError: Cannot read property 'element' of
  undefined
at SafeSubscriber.eval[as _next](PLAYr - conditional.ts: 215)
at SafeSubscriber.__tryOrUnsub(Subscriber.ts: 238)
at SafeSubscriber.next(Subscriber.ts: 190)
at Subscriber._next(Subscriber.ts: 135)
at Subscriber.next(Subscriber.ts: 95)
at Subject.next(Subject.ts: 61)
at PLAYService.validateConditionalEvent(PLAYService.ts: 251)
at PLAYswimmingConditionalRightBar.callPLAYrEvent(PLAY - swimming -
  conditional - right - bar.ts: 3134)
at init.change(PLAY - swimming - conditional - right - bar.ts: 484)
at init.trigger(kendo.all.min.js: 25)

that.PLAYEventDataService = that.PLAYService.conditionalPLAYEventReceived
  .subscribe(params => {
    alert("that.currentPLAYr.element[0].id--->" + that.currentPLAYr
      .element[0].id);
    alert("params.element--->" + params.element);

    if (params.element == that.currentPLAYr.element[0].id) {
      that.template = kendo.template(params.template);
      let eventData = that.timeZoneHandlingNext(params.element,
        params.start, params.end);
      params.start = eventData.start;
      params.end = eventData.end;
      that.PLAYEventReceived = true;
      if (params.changeFrom == "startTimepicker") {
        that.newlySelectedStartTimeFromRightBar = true;
        that.newlySelectedStartTimeFromRightBarValue = params;
      }
      this.isTitleSarch = true;
      that.checkAvailability(params, false, false, "");
      this.isTitleSarch = false;

    }
  })
4b0
  • 21,981
  • 30
  • 95
  • 142

0 Answers0