Angular 2 router no base href set

前端 未结 8 915
半阙折子戏
半阙折子戏 2020-11-22 15:19

I am getting an error and can\'t find why. Here is the error:

EXCEPTION: Error during instantiation of LocationStrategy! (RouterOutlet -> Router -> Loc         


        
8条回答
  •  耶瑟儿~
    2020-11-22 16:03

    I had faced similar issue with Angular4 and Jasmine unit tests; below given solution worked for me

    Add below import statement

    import { APP_BASE_HREF } from '@angular/common';
    

    Add below statement for TestBed configuration:

    TestBed.configureTestingModule({
        providers: [
            { provide: APP_BASE_HREF, useValue : '/' }
        ]
    })
    

提交回复
热议问题