angular2
앱에 typescript
이 있고 나는 ng2-dragula을 사용하고 있습니다. 다음예외 : 정의되지 않은 'addInstrumentToStage'속성을 읽을 수 없습니다.
constructor( private dragulaService: DragulaService,
private audioFinderService:AudioFinderService) {}
및 ngOnInit() : 여기서 생성자이다
public ngOnInit(): any {
this.dragulaService.setOptions('second-bag', {
moves: function (el, container, handle) {
var file=this.audioFinderService.audioGetter();
this.audioFinderService.removeFromStage();
및 라인 this.audioFinderService.audioGetter();
는 불평 :
error_handler.js:50 EXCEPTION: Cannot read property 'audioGetter' of undefined
난의 의존성 주입을 만들려고 생성자는 알지만 인식하지 못하는 것 같습니다. audioFinderService
여기 AudioFinderService에 대한 유일한 이상한 것은, 또 다른 서비스를 주입되어 있다는 것입니다 AudioFinderService
@Injectable()
export class AudioFinderService {
constructor(private playService:SelectedInstrumentsService,private http:Http) { }
}
입니다. 따라서 중첩 된 종속성 주입이 실패했다고 생각하십니까? 대신 지방 화살표 synthax의 function
, 당신은 페이지로 다스 려하는 this
을 잃어 가고 사용하는 경우