我正在使用 Angular 2 Final,并使用 TestBed 进行单元测试
我在使用“ overrideDirective ”时遇到问题,似乎正在调用实际指令,因为我收到错误“ No provider for Config! ” 被替换的 MyDirective 依赖于该错误。
组件视图
<div>
<input myDirective>
// some more logic etc...
</div>
Run Code Online (Sandbox Code Playgroud)
替换指令
@Directive({
selector: "myDirective"
})
class MyDirective{
constructor(
private config: Config
) {
}
}
Run Code Online (Sandbox Code Playgroud)
规格文件
@Component({
template: "<my-component></my-component>"
})
class TestComponent{
}
@Directive({
selector: "fake"
})
class FakeDirective {
}
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
MyComponent,
MyDirective,
TestComponent,
FakeDirective
]
});
});
beforeEach(async(() => {
TestBed
.overrideDirective(MyDirective, FakeDirective)
.compileComponents();
fixture = …Run Code Online (Sandbox Code Playgroud) 我在变量名称之后得到了一个双重括号,我想知道它是什么意思.
以下是什么意思?
Private orgIdField()() As String
Run Code Online (Sandbox Code Playgroud)
我才知道;
Private orgIdField() As String
Run Code Online (Sandbox Code Playgroud)