angular2-routing

RouteParams in Angular 2 rc1

安稳与你 提交于 2020-01-11 01:43:06
问题 I've been trying out Angular 2 since beta, and now with rc.0+ some things have changed. One of those are RouteParams which cannot be imported from @angular/router. And when I try with @angular/router-deprecated I get an error message: ORIGINAL EXCEPTION: No provider for RouteParams! app.component: @Routes([ { path: '/', component: StartComponent }, {path: '/:projId/:userName', component: ProjectListComponent}, { path: '*', component: StartComponent }, ]) project-list.component: import

Angular 2 [routerLink] Not Resolving in Browser

孤街浪徒 提交于 2020-01-07 06:43:08
问题 Without adding too much code or documentation to my question, I'm having a resolving issue with the [routerLink] code for our Angular 2 Demo: Versioning Node.js - v4.4.7 @angular - 2.0.0-rc.1 app/app.component.ts @RouteConfig([ { path: '', name: 'TasksComponent', component: TasksComponent }, { path: 'tasks/editor', name: 'TaskEditorComponent', component: TaskEditorComponent }, { path: 'timer', name: 'TimerComponent', component: TimerComponent } ]) app/app.component.html <nav class="navbar

Angular2 routing - url doesn't change and page doesn't load

佐手、 提交于 2020-01-07 04:59:08
问题 I've started learning angular2 with typescript and I'm trying to implement a route of book/:id but my route doesn't change and the html doesn't neither. I have this file called app.module.ts which has all my other routes which work: app.module.ts import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { UniversalModule } from 'angular2-universal'; import { AppComponent } from './components/app/app.component' import { NavMenuComponent } from '.

What's the right way to set routing for angular2 with koajs

北城余情 提交于 2020-01-07 03:15:30
问题 I'm a newbie to angular2 and koajs. Maybe it's a silly question. I have an angular2 app with a routing table as below: const appRoutes: Routes = [ { path: 'pats/report/settings', component: PatsReportSettingsComponent }, { path: 'pats/report/:id', component: PatsReportComponent, pathMatch: 'full' }, { path: 'pats/report/login', component: PatsLoginComponent, pathMatch: 'full' }, { path: '.', redirectTo: 'pats/report/login', pathMatch: 'full' }, { path: '**', component: Pats404PageComponent,

Angular 2 Login Module with template

放肆的年华 提交于 2020-01-06 19:28:42
问题 I have now One AppModule which has a number of components and one AppCompoennt which is the template componnet with the router-outlet directive. I want in some way create an AuthModule which has its own template AuthComponent between Login, Register Components. When user has logged in it should navigate to the HomeComponent which is rendering in the AppComponent in AppModule. And now the AppComponent is used as long the user is logged in. When user logout. It should navigate back to

Routing through links in Angular2

怎甘沉沦 提交于 2020-01-06 05:39:10
问题 I am new in Angular 2 and I am still in learning phase, but I stuck in a problem and not getting the solution to it. Please help. I have made a view of a login, then a link to it after clicking the link it will redirect to home then clicking a link there it will redirect to some other view. Below is my code structure: app.routing.ts: import { Routes } from '@angular/router'; import { AppComponent } from './app.component'; import { HomeComponent } from './home/home.component'; import {

Angular 2 routerLinkActive

夙愿已清 提交于 2020-01-06 05:00:08
问题 So, I understand how to use RouterLink and RouterLinkActive in the traditional sense. It's pretty easy to define classes that need to be applied but I was curious if you're able to use RouterLinkActive to actually show/hide an element. <div class="btn-group btn-group-justified toggle-nav"> <div class="btn-group"> <button type="button" role="link" class="btn btn-default btn-lg" routerLink="/log-in" routerLinkActive="btn-primary text-bold">Sign In</button> </div> </div> I'm looking to show a

Testing routerLink directive in Angular 2

断了今生、忘了曾经 提交于 2020-01-06 03:58:13
问题 I'm trying to test the work of routing. I moved navbar to a separate component - MdNavbar. Basically only html and css in there, the RouteConfig is in other component and MdNavbar is injected in there. I want to test that route changes when clicking on the link. In test I'm looking for the Profile link and clicking on it. I expect the route to change. Here is the code from my tests - import {it, inject,async, describe, beforeEachProviders, tick, fakeAsync} from '@angular/core/testing'; import

angular 2 routing multi-layer menus

大兔子大兔子 提交于 2020-01-06 03:16:45
问题 I am trying to do multi-level menu routing. The main menu component @Component({ template: ` <h2>Main Menu</h2> <ul> <li><a [routerLink]="['/mainItem1']">Main Item 1</a></li> <li><a [routerLink]="['/mainItem2']">Main Item 2</a></li> more ....... </ul> <router-outlet></router-outlet> `, directives: [RouterOutlet], }) @Routes([ {path: '/mainItem1', component: MainItem1Component }, {path: '/mainItem2', component: MainItem2Component }, more ....... ]) export class MainMenuComponent { } One of the

Prevent Default Routing - Angular 2

眉间皱痕 提交于 2020-01-06 01:54:09
问题 How can I prevent default the routing in angular 2? In router subscribe , I get only the path name. I am not getting event in it. Is there any other service provider in angular 2 to get the route change event? app.component.js (function (app) { app.AppComponent = ng.core .Component({ selector: 'my-app', templateUrl: 'app/views/main.html', directives: [ng.router.ROUTER_DIRECTIVES], viewProviders: [ng.http.HTTP_PROVIDERS] }) .Class({ constructor: [ng.router.Router, ng.http.Http, function