2016-09-19 10 views
0

この指令から私のサービスを呼び出すことはできません。私はwizard.jsでテンプレートを使用してウィザードのモーダルフォームを作成します。私はそれが角度2の問題btwかどうか分からない。ここで角度2の指令からサービスを呼び出すにはどうすればいいですか

は私のディレクティブです:

import {Directive,Input, EventEmitter, ElementRef, Output} from '@angular/core'; 
import {Injectable,Inject} from '@angular/core'; 
import {Service} from '../../../service/service'; 

@Directive ({ 
       selector: '[bootstrap-application-wizard]', 
       providers:[DashboardService] 
     }) 

     export class BootstrapApplicationWizard { 
      $el: any; 
      constructor(
      private _service:Service){} 

      function render(){ 
       wizard.on('submit', function(wizard): void { 
        this.submit = {'data1': 'John','data2': 'Doe'}; 
        this._service.postData('data',this.submit).subscribe(x=>{ 
          console.log('ok'); 
         }); 
       } 

      ngOnInit(){ 
       this.render(); 
      } 
} 

任意のアイデア?

答えて

1

functionを外し、() =>

@Directive ({ 
       selector: '[bootstrap-application-wizard]', 
       providers:[DashboardService] 
     }) 

     export class BootstrapApplicationWizard { 
      $el: any; 
      constructor(private _service:Service){} 

      render(){ 
       wizard.on('submit', (wizard): void => { 
        this.submit = {'data1': 'John','data2': 'Doe'}; 
        this._service.postData('data',this.submit).subscribe(x=>{ 
          console.log('ok'); 
         }); 
       } 

      ngOnInit(){ 
       this.render(); 
      } 
} 
function()を置き換えます
関連する問題