Angular2 and jQuery: How to call component level function?

Viewed 326

Angular2 and jQuery combo is confusing me. Please help! When I invoke a popup dialog, and onApprove case, I want to call Component's level function test(), however, it it causing a run time error:

"TypeError: this.test is not a function"

Any advice is appreciated!

import { Component, OnInit } from '@angular/core';
declare var $: any;

    enter code here

@Component({
  selector: 'app-schedule',
  templateUrl: './schedule.component.html',
  styleUrls: ['./schedule.component.less']
})

export class ScheduleComponent implements OnInit {

  scheduled : boolean;
  constructor() {
    this.scheduled = false;
   }

  ngOnInit() {
  }

  test() {
    console.log('hello');
  }

  deleteConfirmDlg() {
    $('.mini.modal')
      .modal({
        closable  : false,
        onDeny    : function(){
          window.alert('Wait not yet!');
          return false;
        },
        onApprove : function() {
          this.test();
        }
      }).modal('show');
  }
}
1 Answers
Related