小编Kas*_*yap的帖子

OverrideComponent with TestBed

I have MainComponent that uses ChildComponentA as a @ViewChild. MainComponent is calling a method on ChildComponentA.

I want to write an unit test case mocking ChildComponentA. How can I do this using TestBed (in Angular 2 RC5)?

Before I used to use overrideDirective(MainComponentName, ChildComponentA, MockChildComponentA); Is there an equivalent to this using TestBed?

I tried using

TestBed.overrideComponent(ChildComponentA,{
        set: {
          template: '<div></div>'
        }
      }); 
Run Code Online (Sandbox Code Playgroud)

which just sets the template, but I want to mock the methods in …

components overriding testbed angular

6
推荐指数
1
解决办法
9002
查看次数

Angular 2-如何在Canactivate Gaurd中从URL导航

我有page1和page2。我在page2路由上添加了canActivate gaurd,想知道我是否来自page1?我怎么做?

canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
    //If from Page 1 { clearCache() }
    return true;
    }
Run Code Online (Sandbox Code Playgroud)

提前致谢。

url typescript angular

5
推荐指数
2
解决办法
2637
查看次数

标签 统计

angular ×2

components ×1

overriding ×1

testbed ×1

typescript ×1

url ×1