2016-04-21 107 views
-1

我不是Javascript的专家,我意识到我的问题与后续的Typescript代码从那里开始。但是我在这里停留在过去的36小时,以打字稿我有一个不确定的问题,我会让代码解释其余部分:未定义类实现抽象类

window.onload =() => { var i = new IPropIndex(new IPropService()); }; 

interface IIDocService<T> { 
    getSingle(): IPropDoc; 
} 

class IPropService implements IIDocService<T> { 
    getSingle(): IPropDoc { return new IPropDoc(); } 
} 

abstract class IDocIndex<T> { 
    constructor(public _IDocType: string, public _IIDocService: IIDocService<T>) { 
     console.log(this._IDocType); //NOT UNDEFINED 
     this.methodB(); 
    } 

    public abstract methodA(); 

    public methodB() { 
     this.methodA(this.methodC); //**UNDEFINED** 
    } 

    public methodC() { 
     console.log(this._IDocType); 
    } 
} 

class IPropIndex extends IDocIndex<IPropDoc> { 
    constructor(public _IPropService: IPropService) { 
     super('iPROP', _IPropService); 
     console.log(this._IPropService); //NOT UNDEFINED 
    } 

    public methodA(callback: any): void { 
     console.log(this._IPropService); //**UNDEFINED** 
     callback(); 
    } 
} 

class IPropDoc { public name: string; } 

怎样才可以有,而无需不确定的问题,这个解决方案中的代码签署!? 谢谢。

+0

你是如何执行'methodA'和'methodB'? –

回答