angular-router

Angular Cannot reattach ActivatedRouteSnapshot with a different number of children

二次信任 提交于 2019-12-12 12:48:15
问题 Here is my routing in a nativescript-angular project: const routes: Routes = [ { path: "", redirectTo: "/tabs/default", pathMatch: "full" }, { path: "tabs", loadChildren: "~/app/modules/tabs/tabs.module#TabsModule" }, { path: "login", loadChildren: "~/app/modules/login/login.module#LoginModule" }, { path: "register", loadChildren: "~/app/modules/register/register.module#RegisterModule" } ]; @NgModule({ imports: [NativeScriptRouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules

Angular - routerLinkActive and queryParams handling

十年热恋 提交于 2019-12-12 10:48:48
问题 I am using routerLink in Angular as below <li routerLinkActive="active"> <a [routerLink]="['/view', 10]" [queryParams]="{'offset': 0, 'numberOfItems': 100}" queryParamsHandling="merge"> <div>View</div> <div><span class="badge" [innerHtml]="viewCount"></span></div> </a> </li> So the .active class was added to li tag when the URL looks like /view/10?offset=0&numberOfItems=100 If the URL was changed either offset or numberOfItems to a different value, the .active class will be removed, such as.

Why is this http request failing in angular 4, but goes through with fiddler?

房东的猫 提交于 2019-12-12 07:03:58
问题 I have an http post request through fiddler: using http://localhost:58183/api/Account/Register with a body of {"email":"jbjunk4@outlook.com","password":"Abc1231*","confirmPassword":"Abc1231*"} This executes just fine and the email is registered in the identity database on webapi 2. However, I have the following code in my authorize.service.ts: registerUser(localUser: LocalUser) { var headers = new Headers(); headers.append('Content-Type', this.constants.jsonContentType); var creds = JSON

When should href be used instead of routerLink in Angular?

时光毁灭记忆、已成空白 提交于 2019-12-12 03:24:27
问题 When I develop in Angular and create views, I always use the routerLink to navigate from one view to another. Recently I have seen important pages made in Angular that use href instead of routerLink to route views on the website. My question is, when is it convenient to use href instead of routerLink in Angular and why? Is it to give the feeling that it is not a SPA? If so, I do not understand it because it loses the full potential of Angular routing. Some examples are https://brandstory.in/

Returning an Observable<boolean> from canActivate method and redirect on false

南笙酒味 提交于 2019-12-11 18:05:32
问题 I have been searching for a solution with no luck. I need to call the server if a user is authorized and i need canActivate method to wait for the result for that call. But i can`t seem to put pieces together. Below is my code, my question is in the comments of the code. canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> { let user: EUser = new EUser(); user.sessionId = localStorage.getItem("sessionId"); //I am not sure how to implement this part. // I

Angular cdkDrag of Material table rows not working with router-outlet

天大地大妈咪最大 提交于 2019-12-11 16:45:36
问题 I am trying to implement something using Angular Material table, and want to make the rows drag-drop-able. Everything worked fine but after I started to combine it with router-outlet, it stopped working. I create a stackblitz project (https://stackblitz.com/edit/angular-cdkdrag-table-row) that can reproduce the problem. Please open the debug console and you will see the following error message as soon as you try to drag a row TypeError: Cannot read property '_getSiblingContainerFromPosition'

Dynamic queryParams with a routerLink link in Angular

[亡魂溺海] 提交于 2019-12-11 14:41:53
问题 I'm trying to pass a parameter to my routerLink within a loop. Here is what the array of objects looks like: Here is the loop with the routerLink link: <li *ngFor="let Achievement of AllAchievements"> example from multiple sources does not work with a variable 'x'. Outputs the letter x <a routerLink="page" [queryParams]="{x : 1}">anchor text</a> example from multiple sources link is outputted /%5B'page',%20%7BAchievement.type%20:%20'hello'%7D%20%5D' <a routerLink="['page', {Achievement.type :

Nav toolbar and side nav not coming in other components

淺唱寂寞╮ 提交于 2019-12-11 14:21:57
问题 I have searched for this question a lot but still unable to find the solution. In my app, the after successful logging in the page shows the side nav and toolbar. When an item(component) is clicked in side nav, the respective component is displayed but toolbar does not and also side nav. Here are the files I have written, app.component.html <div *ngIf="user_id !== undefined"> <app-applayoutmodel></app-applayoutmodel> </div> <div class="container"> <router-outlet></router-outlet> </div> app

Show component in nested router

蹲街弑〆低调 提交于 2019-12-11 10:54:49
问题 I want to route to "config" router, which is nested 2 outlets deep but I'm unable to figure out the correct way to do so. <router> <router name="main"> <router name="config"> </router> </router> </router> In my routing.ts, I created 2 ways to reach the component: export const routes: Routes = [ { // Entrypoint. path: 'Foo', component: FooComponent, canActivate: [IsServerOnlineGuard], children: [ path: 'Bar', component: BarComponent, outlet: 'main', children: [ { path: 'Smtp', component:

Angular: How to navigate to child route from parent component by using navigate method

随声附和 提交于 2019-12-11 07:47:27
问题 Here is my html rouerLink: <a [routerLink]="['create']">Create</a> - works fine. on button click I am calling the same as: But not works.. navigateTo(page) { this.router.navigate(['create']); //not works } Any one help me, what is really I am missing here? UPDATE I am navigating from parent to child here is the routes: { path: 'contentPlaceholder', data: { showNavi: true }, component: ShellContentPlaceholderComponent, children : [ { path: 'view', data: { showNavi: false }, component: