当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Router.initialNavigation方法代码示例

本文整理汇总了TypeScript中@angular/router.Router.initialNavigation方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Router.initialNavigation方法的具体用法?TypeScript Router.initialNavigation怎么用?TypeScript Router.initialNavigation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/router.Router的用法示例。


在下文中一共展示了Router.initialNavigation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should navigate back', fakeAsync(() => {
    const {fixture, rootRenderer} = initTest(TestComponent, `<View><router-outlet></router-outlet></View>`);
    const location: LocationStrategy = getTestBed().get(LocationStrategy);
    const router: Router = getTestBed().get(Router);
    router.initialNavigation();
    tick();
    fixture.detectChanges();
    rootRenderer.executeCommands();
    expect(mock.commandLogs.toString()).toEqual(
      'CREATE+2+test-cmp+{},CREATE+3+native-view+{},CREATE+4+router-outlet+{},ATTACH+1+2+0,ATTACH+2+3+0,ATTACH+3+4+0,' +
      'CREATE+5+cmp-a+{},CREATE+6+native-text+{},CREATE+7+native-rawtext+{"text":"a"},ATTACH+6+7+0,ATTACH+5+6+0,ATTACH+3+5+1');
    mock.clearLogs();

    router.navigateByUrl('/b')
      .then((_: any) => {
        tick();
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'CREATE+8+cmp-b+{},CREATE+9+native-text+{},CREATE+10+native-rawtext+{"text":"b"},DETACH+3+1,ATTACH+3+8+1,ATTACH+9+10+0,ATTACH+8+9+0');
        mock.clearLogs();
      })
      .then((_: any) => {
        location.back();
        tick();
        fixture.detectChanges();
        rootRenderer.executeCommands();
        expect(mock.commandLogs.toString()).toEqual(
          'CREATE+11+cmp-a+{},CREATE+12+native-text+{},CREATE+13+native-rawtext+{"text":"a"},DETACH+3+1,ATTACH+3+11+1,ATTACH+12+13+0,ATTACH+11+12+0');
      });
  }));
开发者ID:angular,项目名称:react-native-renderer,代码行数:31,代码来源:router_spec.ts

示例2: flush

 fixture.ngZone.run(() => {
   router = TestBed.get(Router);
   router.initialNavigation();
   // Generate breadcrumb items.
   router.navigate([ 'one', 'two', 'three', 'four' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   items = fixture.debugElement.queryAll(By.directive(NzBreadCrumbItemComponent));
   // Should generate 2 breadcrumbs when reaching out of the `data` scope.
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(2);
   dispatchMouseEvent(items[ 1 ].nativeElement.querySelector('a'), 'click');
   router.navigate([ 'one', 'two', 'three' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(2);
   router.navigate([ 'one', 'two' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(1);
   router.navigate([ 'one' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   // Shouldn't generate breadcrumb at all.
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(0);
 });
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:29,代码来源:nz-breadcrumb.spec.ts

示例3: beforeEach

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        RouterTestingModule,
        HttpClientModule,
        LoadingModule
      ],
      declarations: [
        BusyIndicatorComponent,
        AppComponent
      ],
      providers: [
        AlertService,
        { provide: UserService, useClass: MockUserService },
        { provide: ComicService, useClass: MockComicService },
      ],
    }).compileComponents();

    fixture = TestBed.createComponent(AppComponent);
    component = fixture.componentInstance;

    user_service = TestBed.get(UserService);
    alert_service = TestBed.get(AlertService);
    comic_service = TestBed.get(ComicService);
    router = TestBed.get(Router);

    fixture.detectChanges();
    router.initialNavigation();
  }));
开发者ID:woocommerce-quiz,项目名称:comixed,代码行数:29,代码来源:app.component.spec.ts

示例4: beforeEach

  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent,
        LoginComponent,
        HomeComponent
      ],
      imports: [
        BrowserModule,
        HttpModule,
        FormsModule,
        BrowserAnimationsModule,
        MatCheckboxModule,
        MatTabsModule,
        MatGridListModule,
        MatToolbarModule,
        FlexLayoutModule,
        MatCardModule,
        MatInputModule,
        Ng2SearchPipeModule,
        MatSidenavModule,
        RouterModule,
        RouterTestingModule.withRoutes(appRoutes),
      ],
      providers: [{ provide: APP_BASE_HREF, useValue: '/' }
    ],
    });

    router = TestBed.get(Router);
    location = TestBed.get(Location);

    fixture = TestBed.createComponent(AppComponent);
    router.initialNavigation();

  });
开发者ID:ianasjl,项目名称:real-chat,代码行数:35,代码来源:app.component.spec.ts

示例5:

 authService.initCurrentUser().then(success => {
     router.initialNavigation();
     url = url.replace("#_=_", "");
     if(url != '/' && url != '/discover')
         this.router.navigate([url, params]);
     if(this.authService.isLoggedIn && url == '/')
         this.router.navigate([url]);
 });
开发者ID:OlivierCoue,项目名称:invow,代码行数:8,代码来源:tc-app.component.ts

示例6: Router

 useFactory: (
   resolver:ComponentResolver,
   urlSerializer:UrlSerializer,
   outletMap:RouterOutletMap,
   location:Location,
   injector:Injector) => {
   const r = new Router(TestComponent, resolver, urlSerializer, outletMap, location, injector, config);
   r.initialNavigation();
   return r;
 },
开发者ID:martinsvb,项目名称:Angular2_bootstrap_seed,代码行数:10,代码来源:app.component.spec.ts

示例7: createRootWithRouter

export function createRootWithRouter(
  router: Router,
  type: any,
): ComponentFixture<any> {
  const f = TestBed.createComponent(type);
  advance(f);
  router.initialNavigation();
  advance(f);
  return f;
}
开发者ID:catrielmuller,项目名称:angulartics2,代码行数:10,代码来源:test.mocks.ts

示例8: createComponent

function createComponent() {
  fixture = TestBed.createComponent(AppComponent);
  comp = fixture.componentInstance;

  const injector = fixture.debugElement.injector;
  location = injector.get(Location) as SpyLocation;
  router = injector.get(Router);
  router.initialNavigation();
  spyOn(injector.get(TwainService), 'getQuote')
    // fake fast async observable
    .and.returnValue(asyncData('Test Quote'));
  advance();

  page = new Page();
}
开发者ID:BobChao87,项目名称:angular,代码行数:15,代码来源:app.component.router.spec.ts

示例9: beforeEach

  beforeEach(fakeAsync(() => {

    TestBed.configureTestingModule({
      imports: [
        FormsModule,
        HttpModule,
        Ng2SearchPipeModule,
        RouterTestingModule.withRoutes(appRoutes)
       ],
       providers: [
        ChatService,
        HttpService,
        MockBackend,
        BaseRequestOptions,

        {
          provide: Jsonp,
          useFactory: (backend, options) => new Jsonp(backend, options),
          deps: [MockBackend, BaseRequestOptions]
        },
        {
          provide: Http,
          useFactory: (backend, options) => new Http(backend, options),
          deps: [MockBackend, BaseRequestOptions]
        }

       ],

      declarations: [ HomeComponent, LoginComponent]

    });

      router = TestBed.get(Router);
      location = TestBed.get(Location);

      fixture = TestBed.createComponent(HomeComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();


      router.initialNavigation();

    backend = TestBed.get(MockBackend);
    service = TestBed.get(ChatService);

  }));
开发者ID:ianasjl,项目名称:real-chat,代码行数:46,代码来源:home.component.spec.ts


注:本文中的@angular/router.Router.initialNavigation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。