从角度为2的jquery调用TypeScript方法

Pra*_*gam 10 typescript angular2-forms typescript2.0 angular

我正在使用带有jquery的带角度2形式的boostrap-select Dropdown.Onchange jquery事件我想调用一个Typescript onDropDownChangeChange方法.但它不起作用.

import { Component, OnInit, ViewChild } from '@angular/core';
import { RequestOptions } from '@angular/http';
import 'rxjs/add/observable/throw';
declare var $: JQueryStatic;

export class TestComponent implements OnInit {
  selectedValue: string;

  ngOnInit(): void {

        $(function() {
         var self = this;
          $('.selectpicker').on('change', function(){
            var selectedds = $(this).find('option:selected').val();
            self.onDropDownChangeChange(selectedds); //This is not working
            //this.onChange();
          });

        });  

  }

  onDropDownChangeChange(value: string) {
        this.selectedValue = value;
        this.PopulateGrid(selectedValue);
   }


}
Run Code Online (Sandbox Code Playgroud)

eko*_*eko 22

你混淆范围.它应该是这样的:

ngOnInit(): void {

    var self = this;
    $(function() {

          $('.selectpicker').on('change', function(){

              var selectedds = $(this).find('option:selected').val();
              self.onDropDownChangeChange(selectedds); //This is not working
              //this.onChange();

           }); 

    }); 
}
Run Code Online (Sandbox Code Playgroud)