angular-router

Angular routerLinkActiveOptions

左心房为你撑大大i 提交于 2020-01-16 19:30:15
问题 I have some link like this <li routerLinkActive="active" class="nav-item"> <a [routerLink]="['contracts']" [queryParams]="{ activeOnly: false }" class="nav-link">Contracts</a> </li> You see here in params i have ?activeOnly=false with this approach all is ok when my url is like contracts?activeOnly=false active css class is added in html and user can see that it is active link The problem I have that sometimes url can be changed like this contracts?activeOnly=true&id=1 then active css does

CanActivate guards on child routes run before parent Resolve finish

放肆的年华 提交于 2020-01-13 09:06:59
问题 I'm trying to resolve data before navigating to children routes as i have to use that data in children guard. The issue is parent resolver, resolves data after the child guard is fired. Resolver takes long time to resolve data // app.module.ts const appRoutes: Routes = [ { path: 'login', component: LoginComponent }, { path: '', component: SiteLayoutComponent, children: [ { path: '', redirectTo: 'warehouse', pathMatch: 'full' }, { path: 'warehouse', loadChildren: './warehouse/warehouse.module

Angular reuse same lazy load module for multiple root paths

ⅰ亾dé卋堺 提交于 2020-01-12 14:29:34
问题 I've splitted my app into two modules: one with main basic functionality and other with less-used features like account settings, faq pages and more. What I'm trying to accomplish is to lazy load the second module for some root route paths, like /account or /settings without having to create many different modules. As far as I know Angular lazy load only works with one root route, and the routes configured in the lazy loaded module are set as children of that route. { path: 'account',

Is it possible to prevent the destruction of Angular components when navigating?

我们两清 提交于 2020-01-12 07:30:13
问题 Assuming I have two Angular 2 components: ComponentA and ComponentB . I want to be able to navigate from ComponentA to ComponentB and then eventually back to ComponentA, while not having to reinitialize ComponentA. In the current Angular 2 Router implementation, every time I navigate away from a component, the component gets destroyed and has to be recreated the next time I navigate to it. I know that I can preserve the state of components by using a Service, but this seems to be more like a

Angular 2 get parent activated route

。_饼干妹妹 提交于 2020-01-11 08:43:08
问题 I have a route with route children like this: { path: 'dashboard', children: [{ path: '', canActivate: [CanActivateAuthGuard], component: DashboardComponent }, { path: 'wage-types', component: WageTypesComponent }] } And in the browser I want to get the activated parent route like host.com/dashboard/wage-types How to get the /dashboard but possible with Angular 2 and not in JavaScript, but also I can accept JavaScript code too but primary Angular 2. 回答1: You can do this by using the parent

Angular 2 Route Param automatically converting to lowercase on localhost but remains capitalized on server

余生颓废 提交于 2020-01-07 05:48:05
问题 I currently have a .NET angular 2 program, with a route styled as <ControllerName>/:id Run on localhost with IIS Express, the id route param automatically converts to lowercase in the URL without me expressly doing any extra formatting. When calling the same controller and using matrix notation to input ID, however, it loses it's ability to automatically become lowercase <ControllerName>;id=<CAPSGUID> Curious thing is, when I host this on an IIS server, this functionality is somehow lost and

Angular 4 create different language path route to the same component

╄→гoц情女王★ 提交于 2020-01-06 07:15:30
问题 I want to create the multi-language support for the website. I'm currently using ngx-translate to translate all the text . Let's way we have two urls, mypage/en/home and mypage/es/home. How can I create those language paths and route them to home component? 回答1: Updated based on comment: In the routes for the router you can do something like this: export const routes: Routes =[ { path: 'mypage/:language/home', component: HomeComponent } ] This way you actually only need one route and can have

Angular Router URL Encoding Special Characters and Browser Behavior

巧了我就是萌 提交于 2020-01-06 05:22:48
问题 I just can't figure out the solution for such problem. I'm designing search engine and I'd like to display in url what user is trying to find like this: https://my-site.com/search;query=%28rockstar;search=true;page=0 User is trying to find (rockstar phrase. When I paste this url to the browser it works as expected but the Chrome browser is displaying this url like this: https://my-site.com/search;query=(rockstar;search=true;page=0 So the %28 is changed to ( . I don't know if this behavior is

Angular Router URL Encoding Special Characters and Browser Behavior

谁说胖子不能爱 提交于 2020-01-06 05:22:15
问题 I just can't figure out the solution for such problem. I'm designing search engine and I'd like to display in url what user is trying to find like this: https://my-site.com/search;query=%28rockstar;search=true;page=0 User is trying to find (rockstar phrase. When I paste this url to the browser it works as expected but the Chrome browser is displaying this url like this: https://my-site.com/search;query=(rockstar;search=true;page=0 So the %28 is changed to ( . I don't know if this behavior is

Ionic 4 Angular router navigate and clear stack/history of previous page

扶醉桌前 提交于 2020-01-05 15:25:13
问题 I'm developing an app using Ionic 4 with Angular router. I would like to navigate to another page and clear the page stack. In Android native, it's something like this: Intent intent = new Intent(NewActivity.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); From what I've read so far, it is possible using Ionic NavController but it is deprecating in Ionic 4. I learnt about buttons with routerLink but if I'm not mistaken, by using that the app