angular2-routing

Angular2: What's the equivalent of the router 'loadChildren' without lazy loading

孤街醉人 提交于 2019-12-18 16:47:48
问题 I'm trying 'plug' a sub ngModule (a feature module ) containing routing configurations (imported from RouterModule.forChild() ) into a parent ngModule. When using lazy loading, specifying where to 'plug' the child module is done using the loadChildren key in the parent module route configuration. ex: export const parentModuleRouteConfig = [{ path: 'myfeaturemodule', loadChildren: '/app/child.module' }]; Actually, i don't whant to use lazy loading . How can i tell the router to 'plug' (or use)

how to pass RouteData via Router.navigate in angular2

半世苍凉 提交于 2019-12-18 15:50:14
问题 Is there an api in agnular2 that allows passing json objects instead of string values . E.g. In Router.navigate() I can pass route parameters Router.navigate('routename',[{key:stringvalue}]) and can retrieve it using RouteParams.get(key) : string . But this returns just string values. I need to pass the json object. Appreciate any pointers 回答1: I think that it's not something possible out of the box since routing relies on URLs and both path variables and query parameters are strings. Both

How to change parent variable from children component?

白昼怎懂夜的黑 提交于 2019-12-18 15:17:45
问题 This question is quite simple but I can't get rid of it. I have a <header> in parent template and I need it disappear when displaying children template through routing module. What I expect is adding a class to the header tag so I can hide it via CSS. This is what I have: app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app', template: ` <header [class.hidden]="hide"> <h1>My App</h1> <ul> <li><a href="/home"></a></li> <li><a href="/showoff"></a></li> </ul> <

RouterLinkActive for RouterLink with parameters (/dynamic)

半世苍凉 提交于 2019-12-18 14:13:07
问题 RouterLinkActive is not working when using a dynamically generated link when navigating through the app itself. e.g. in my top navigation i have this; <a [routerLink]=['user', currentUser.name] routerLinkActive='active'>{{currentUser.name}}</a> Whilst the hardcoded version would work. <a [routerLink]=['user','bob']>View Bobs Account</a> A plunk for this is here; https://plnkr.co/edit/BYKMucE3Y75uJSpV5VWx?p=preview Click on "John" and "Dynamic Router Link Name = " and "John" should both be

Lazy Loading BrowserModule has already been loaded

﹥>﹥吖頭↗ 提交于 2019-12-18 14:08:12
问题 I am trying to implement lazy loading but getting error as following ** ERROR Error: Uncaught (in promise): Error: BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead. ** Need Help on this. Here are my Modules Shared MOdule @NgModule({ declarations: [TimePipe], providers: [ EmsEmployeeService, EmsDesignationService, EmsOrganizationService, EmsAuthService, AmsEmployeeService,

Microsoft Edge adds parameters after navigating to a route on angular 2

我们两清 提交于 2019-12-18 13:30:50
问题 I have a form being filled in two steps, the first form fills in the main part of an object and the second, the sub-part. There is a method that navigates back from form2 to form1 that works on Chrome and Firefox, but with Microsoft Edge it seems to add "/?object", and it's something that I'm not doing in code. my button to go back from form2 to form1 <button class="btn btn-default pull-right" (click)="onCancel()">{{ 'button.back' | translate }}</button> my method onCancel() onCancel() { this

How to lazy load a route as a child route/component

喜夏-厌秋 提交于 2019-12-18 13:26:46
问题 Let's take a look at my plunker: https://plnkr.co/edit/22RIoGsvzfw2y2ZTnazg?p=preview I want to lazy load a Module as a child-route. So the route /lazy should render the LazyModule into the <router-outlet> of my MainComponent . Then it will switch between that DummyComponent and the lazy loaded Module. Instead now that lazy loaded Module will be rendered into the AppComponent .. Any ideas? 回答1: If you want to lazy load a module, do not import it as you've done here : src/app.ts : import {

Multiple layouts in nested routes in Angular (2+)

对着背影说爱祢 提交于 2019-12-18 12:46:04
问题 I'm creating a Dashboard like application. I'd like to achieve the following layout plan in Angular (2+): route - name - layout / - home page - full width layout with tables and charts, etc /reports - reports page - same full width layout with more tables, etc /login - login page - no full width layout, just a simple login form at screen center /signup - signup page - no full width layout, just a simple signup form at screen center /messages - emails - full width layout /messages/new - new

Hide elements based on routing in Angular2 rc1

两盒软妹~` 提交于 2019-12-18 11:28:11
问题 I have some elements I want on every page except the login page. I'd like to use ngIf or possibly the hidden property of the elements to hide those elements when the user is on the login page. I have tried this: <div [hidden]="router.isRouteActive(router.generate('/login'))"> based on this question and answer: In Angular 2 how do you determine the active route? And have also tried this: <div *ngIf="!router.isRouteActive(router.generate('/login'))"> but haven't had any success. For reference

After hosting Angular2 app on IIS direct url is not working

陌路散爱 提交于 2019-12-18 10:46:24
问题 We have developed Angular2 App. It is working fine while we are running under angular-cli with 'ng serve'. Once we host the app to IIS 7.5, we can browse to root of the app without much of the problem and we can navigate to whatever other views from app navigation created. But issue starts when user try to load url which is targeting specific route or component. so if we go to http://serverurl ... it loads index.html and then clicking on navigation link on index.html it takes user to http:/