angular2-routing

Unexpected value 'undefined' declared by the module 'AppModule'

你离开我真会死。 提交于 2019-12-02 21:34:06
What is wrong here? I'm trying to make it work but I get that error in the header. I have included the <router-outlet></router-outlet> in the app.component.html that is being templateUrl called by the app.component.ts , still no luck. app.module.ts : import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { RouterModule, Routes } from '@angular/router'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { TopnavComponent } from '.

How to reload page the whole page in Angular 2? [closed]

本秂侑毒 提交于 2019-12-02 17:23:49
How can I reload the current page on Angular via TypeScript? I don't want to change the URL parameters, only to reload. This should technically be achievable using window.location.reload() : HTML: <button (click)="refresh()">Refresh</button> TS: refresh(): void { window.location.reload(); } Update: Here is a basic StackBlitz example showing the refresh in action. Notice the URL on "/hello" path is retained when window.location.reload() is executed. Hopefully that helps! 来源: https://stackoverflow.com/questions/43985752/how-to-reload-page-the-whole-page-in-angular-2

Can't bind to 'routerLink' since it isn't a known property

孤街醉人 提交于 2019-12-02 16:55:23
Recently, I have started playing with angular 2. It's awesome so far. So, i have started a demo personal project for the sake of learning using angular-cli . With the basic routing setup, I now want to navigate to some routes from header, but since my header is a parent to the router-outlet , I receive this error. app.component.html <app-header></app-header> // Trying to navigate from this component <router-outlet></router-outlet> <app-footer></app-footer> header.component.html <a [routerLink]="['/signin']">Sign in</a> Now I understand partially I guess that since that component is a wrapper

Routing between modules in Angular 2

◇◆丶佛笑我妖孽 提交于 2019-12-02 16:42:31
I'm writing an application where all features got it's own module (A feature could be a page, or a part of a page). This because we want all features to have it's own domain logic, services, directives and components, i.e. in the dashboard module we got an ChartComponent widget that I don't want to expose to other views like login or profile. The problem is when working with routing in Angular 2 you always routes to a particular component, not a module. In our case, to set up a route for path: '/dashboard' component: DashboardComponent we need to declare DashboardComponent in app.module.ts,

Angular 2 RC4 Router get intended route before activated

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 16:38:33
问题 I am trying to determine what the route is before it is activated so I can cache it and redirect the user back to that route after they have logged in. In the old beta router I was able to call ComponentInstruction.routeName in the activate hook but in the newer canActivate() guard I do not see a way to access the intended route before it is activated. I could store the intended route in a shared service when the user clicks on a navagtion button in my app but what about when they enter the

angular 2/4 routing with named outlet?

匆匆过客 提交于 2019-12-02 13:58:16
问题 I am trying to do implement named outlet in my app. Here is my route config: { path: 'contact', children: [ { path: '', component: ContactComponent, pathMatch: 'full' }, { path: 'list', component: ContactlistComponent }, { path: 'hold', component: ContactOperationComponent, outlet: 'popup' } ] } Here is Outlet which i have kept in AppComponent with main router-outlet <router-outlet name="popup"></router-outlet> And here is my routerLink which is calling my Component : <a [routerLink]="['

How to fix: Error in app/app.component.html:15:1 caused by: No provider for RouterOutletMap

好久不见. 提交于 2019-12-02 11:04:30
问题 I found these answers here, but they did not help me. I guess Angular 2 is still in flux? No provider for RouterOutletMap Getting Angular2 error 'No provider for Router! (RouterOutlet -> Router)' My app.routing.ts import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { AboutComponent } from './about/about.component'; import { ContactComponent } from './contact/contact.component

Angular 2 RC4 Router get intended route before activated

六眼飞鱼酱① 提交于 2019-12-02 09:01:05
I am trying to determine what the route is before it is activated so I can cache it and redirect the user back to that route after they have logged in. In the old beta router I was able to call ComponentInstruction.routeName in the activate hook but in the newer canActivate() guard I do not see a way to access the intended route before it is activated. I could store the intended route in a shared service when the user clicks on a navagtion button in my app but what about when they enter the URL in the address bar? From angular router source files: export interface CanDeactivate<T> {

Passing params angular 2 traditional way

风流意气都作罢 提交于 2019-12-02 07:52:27
I am trying to pass parameters to one component in this format www.domain.com?param=value , but Angular keep sending parameters like this www.domain.com;param=value . Why replace ? for ; ? This is my route conf: const router: Routes = [ {path: '', redirectTo: '/shops', pathMatch: 'full'}, {path: 'shops', component: ShopComponent, canActivate: [AuthManager]}, {path: 'shop/new', component: NewShopComponent, canActivate: [AuthManager]}, {path: 'shop/new/:id', component: NewShopComponent, canActivate: [AuthManager]}, {path: 'login', component: LoginComponent}, {path: 'register', component:

Angular: take user to home on clicking browser back button [duplicate]

久未见 提交于 2019-12-02 07:21:26
问题 This question already has answers here : History push state redirects instead of just pushing new state to browser history (2 answers) Closed 8 months ago . I want to take the user to the home page when a user clicks on the back button of the browser if the user is in my angular platform. There is an edge case as well which is to be handled, if user has come to our platform via google search, Fb or direct entering link, then we cant this behavior but if he ia already roaming around in our