angular2-routing

Multiple components per route in angular

半城伤御伤魂 提交于 2020-01-04 11:03:32
问题 What I want to do is, I want to load the home component and sidebar component at the same time. const appRoutes: Routes = [ { path: '', component: HomeComponent, children: [{ path: 'sidebar', component: SidebarComponent, children: [ { path: 'about', component: AboutComponent }, { path: 'clients', component: ClientsComponent }, { path: 'services', component: ServicesComponent }, { path: 'contact', component: ContactComponent }, { path: 'datatable', component: DataComponent } ] }] } 回答1: You

Multiple components per route in angular

半世苍凉 提交于 2020-01-04 11:01:45
问题 What I want to do is, I want to load the home component and sidebar component at the same time. const appRoutes: Routes = [ { path: '', component: HomeComponent, children: [{ path: 'sidebar', component: SidebarComponent, children: [ { path: 'about', component: AboutComponent }, { path: 'clients', component: ClientsComponent }, { path: 'services', component: ServicesComponent }, { path: 'contact', component: ContactComponent }, { path: 'datatable', component: DataComponent } ] }] } 回答1: You

Is there any downside of HashLocation Strategy?

瘦欲@ 提交于 2020-01-04 05:36:27
问题 I am currently learning Angular. I have implemented routers using HashLocation, because PathLocation is not working in Apache server. I went through various posts to solve that, but in the end have to settle with HashLocation for Apache. I just want to know that if there is any downside of HashLocation, like is there any Angular feature that does not work with HashLocation and can I use HashLocation for production ready apps? 回答1: According to, https://angular.io/docs/ts/latest/guide/router

Angular 2 - children component in parents router outlet

▼魔方 西西 提交于 2020-01-04 02:41:10
问题 I am currently trying to implement an angular 2 application with multiple navigation levels. The problem is that my child components cannot find a router outlet when it is not explicitly declared in the parent component from my routes. This is the error message i get: Unhandled Promise rejection: Cannot find primary outlet to load 'EditUserComponent' I want something like an edit or detail view which shows instead of the list view when i click on a button or link. The views are embedded in a

How to give correct path names for loadchildren in lazy loading angular 2 NgModule?

为君一笑 提交于 2020-01-03 16:44:56
问题 How to give correct path names for loadchildren in app-routing.module file in the angular 2 ngmodule, I followed the ngmodule concept in angular main website but its not giving such informations. I am getting the issue with app-routing.module paths,what i need to specify in the path names, with this issue, lazy loading is not working.all files are loading once yet a time ,can anyone help ? what i miss in the paths loadchildrens ? followed this Angular NgModule app-routing.module file. import

Angular2 pathLocationStrategy: url change cause page reload

烈酒焚心 提交于 2020-01-03 08:26:51
问题 While using HashLocationStrategy I can change route by changing address in browser's address bar by hand without page reload. I.e. navigation from mysite/#/home to mysite/#/profile However, if I use PathLocationStrategy (it is default location strategy), I have unwanted page reload, when I try to do the same thing. I.e. navigation from mysite/home to mysite/profile Is it possible to fix this? I am using Angular 2.0.0-beta17 回答1: That's "as designed". When you only change the #... then there

how to get route parameters in angular2 RC5

二次信任 提交于 2020-01-03 07:22:10
问题 I have upgraded my angular2 project to RC5 using angular-cli@webpack . I have provide routing as below: const appRoutes: Routes = [ { path: 'project-manager', component: ProjectManagerComponent }, { path: 'designer/:id', component:DesignerComponent } , {path: '',redirectTo: '/project-manager',pathMatch: 'full'} ]; and I am redirecting to designer Component using routerLink as : <a [routerLink]="['/designer', page._id]"><i class="fa fa-eye fa-fw"></i></a> Now It is getting redirected

What are Router Bindings actually used for

拜拜、爱过 提交于 2020-01-03 07:00:08
问题 What are Router Bindings actually used for in Angular2 router. specially the Router 3.0 (newest Angular RC4 router)? Any working code or plunker? https://angular.io/docs/ts/latest/api/router-deprecated/index/ROUTER_BINDINGS-let.html 回答1: The name was just changed from ROUTER_BINDINGS to ROUTER_PROVIDERS as were the bindings parameter of the @Component() , @Directive() or @Pipe() decorator was renamed to providers and they actually are the router implementation and services provided by the

Route without parameter value; Angular route redirect - Can I use redirectTo to parameter path?

假装没事ソ 提交于 2020-01-03 02:47:12
问题 I'm wandering if it is possible to redirect path: ' ' to path: ':id' ? Is there a way I can achieve this? Thank you. { path: 'folder', children: [ { path: '', redirectTo: ':id', pathMatch: 'full', }, { path: ':id', canActivate: [AuthGuard], component: DocumentsComponent, }, ] } 回答1: I found a way to redirect 'folder' route to 'folder/:id' with empty 'id' parameter: { path: 'folder', redirectTo: 'folder/', pathMatch: 'full', }, { path: 'folder', children: [ { path: ':id', canActivate:

how to convert byte array to image in Angular2

丶灬走出姿态 提交于 2020-01-03 02:22:09
问题 I am getting byte array from api and i have applied image tag on my HTML page as <img src="data:{{model.asd_logo_type}};base64,{{model.dfgh_logo}}" alt="..."> but i am not able to get the image on display. Please suggest what can i do. 回答1: you can use src directive to display image in angular <img [src]="'data:image/jpeg;base64,'+model.dfgh_logo" /> This is how I achieved. model.dfgh_logo this should have image in byte array. 来源: https://stackoverflow.com/questions/48781966/how-to-convert