How to use the @angular/router.Routes function in @angular/router

To help you get started, we’ve selected a few @angular/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pikoscielniak / notifier / src / web / wwwroot / app / app.component.ts View on Github external
import {MainPageComponent} from "./+main-page/main-page.component";
import {DashboardComponent} from "./+dashboard/dashboard.component";

declare var componentHandler:any;

@Component({
    selector: 'notifier',
    templateUrl: 'app/app.component.html',
    directives: [ConfirmComponent, ROUTER_DIRECTIVES],
    providers: [
        ROUTER_PROVIDERS,
        ConfirmService,
        AuthManager
    ]
})
@Routes([
    {path: '/main-page', component: MainPageComponent},
    {path: '/dashboard', component: DashboardComponent}
])
export class AppComponent implements OnInit {

    title = "Notifier!!!";

    constructor(private _confirmService:ConfirmService,
                private _authManager:AuthManager,
                private _router:Router) {
    }

    showConfirmDialog() {
        this._confirmService.activate("Are you sure?")
            .then(res => console.log(`Confirmed: ${res}`));
    }
github danielschmitz / angular2-codes / 07 / AngularRoutes / app / app.component.ts View on Github external
import {LoginComponent} from './login/login.component'

@Component({
    selector: 'my-app',
    directives: [ROUTER_DIRECTIVES],
    template: `
            <h1>My First Angular 2 App</h1>
            <ul>
                <li><a>Home</a></li>
                <li><a>Login</a></li>
                <li><a>Dashboard</a></li>
            </ul>
            <div></div>
            `
})
@Routes([
    { path: '/home', component: HomeComponent },
    { path: '/login', component: LoginComponent },
    { path: '/dashboard',  component: DashboardComponent }
])
export class AppComponent { }
github Farata / angular2typescript / chapter3 / basic_routing / app / main_child_route.ts View on Github external
import {LocationStrategy, HashLocationStrategy} from '@angular/common';
import {Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';

import {HomeComponent} from './components/home';
import {ProductDetailComponent} from './components/product_child_route';

@Component({
    selector: 'basic-routing',
    directives: [ROUTER_DIRECTIVES],
    template: `
        <a>Home</a>
        <a>Product Details</a>
        
    `,
})
@Routes([
    {path: '/',            component: HomeComponent},
    {path: '/product/:id', component: ProductDetailComponent}
])
class RootComponent{}

bootstrap(RootComponent, [
    ROUTER_PROVIDERS,
    {provide: LocationStrategy, useClass: HashLocationStrategy}
]);
github Farata / angular2typescript / chapter3 / basic_routing / app / components / product_child_route.ts View on Github external
import {SellerInfoComponent} from './seller';
import {ProductDescriptionComponent} from './product_description';

@Component({
    selector: 'product',
    styles: ['.product {background: cyan}'],
    directives: [ROUTER_DIRECTIVES],
    template: `
      <div class="product">
        <h1>Product Detail for Product: {{productID}}</h1>
        
        <p><a>Seller Info</a></p>
      </div>
    `
})
@Routes([
    {path: '',            component: ProductDescriptionComponent},
    {path: 'seller/:id',  component: SellerInfoComponent}
])
export class ProductDetailComponent {
  productID: string;

  constructor(params: RouteSegment) {
    this.productID = params.getParam('id');
  }
}
github clamarque / Angular2_Dashboard / src / app / old_home / home.component.ts View on Github external
import { MissionViewComponent } from "../mission/mission-view.component";
import { RoleIndexComponent } from '../role/role-index.component';
import { RoleCreateComponent } from '../role/role-create.component';
import { SettingIndexComponent } from '../setting/setting-index.component'
import { SkillIndexComponent } from '../skill/skill-index.component';
import { SkillCreateComponent } from '../skill/skill-create.component';
import { SkillViewComponent } from '../skill/skill-view.component';
import { UserRegisterComponent } from '../user/user-register.component';

@Component({
    selector: 'home',
    templateUrl: './dev/home/home.component.html',
    directives: [ROUTER_DIRECTIVES],
    providers: [DataService, ObjectToArrayPipe]
})
@Routes([
    { path: '/', component: HomeIndexComponent },
    { path: '/Mission', component: MissionIndexComponent },
    { path: '/CreateMission', component: MissionCreateComponent },
    { path: '/ViewMission/:id', component: MissionViewComponent },
    { path: '/Collaborator', component: CollaboratorIndexComponent },
    { path: '/CreateCollaborator', component: UserRegisterComponent },
    { path: '/ViewCollaborator/:id', component: CollaboratorViewComponent },
    { path: '/Customer', component: CustomerIndexComponent },
    { path: '/CreateCustomer', component: CustomerCreateComponent },
    { path: '/ViewCustomer/:id', component: CustomerViewComponent },
    { path: '/Setting', component: SettingIndexComponent },
    { path: '/Skill', component: SkillIndexComponent },
    { path: '/CreateSkill', component: SkillCreateComponent },
    { path: '/ViewSkill/:id', component: SkillViewComponent },
    { path: '/Role', component: RoleIndexComponent },
    { path: '/CreateRole', component: RoleCreateComponent }
github thangufo / spring-angular2-realtime-dashboard / src / main / resources / public / app / app.component.ts View on Github external
import {Component} from '@angular/core';
import {Http, HTTP_PROVIDERS} from '@angular/http';
import { Poll } from './domain/poll.domain';
import { PollListComponent } from './poll.list.component';
import { DashboardComponent } from './dashboard.component';
import { Router,ROUTER_DIRECTIVES, Routes } from '@angular/router';

@Component({
    selector: 'my-app',
    templateUrl: 'templates/index.html',
    directives: [ROUTER_DIRECTIVES]
})
@Routes([
  {path: '/dashboard', component: DashboardComponent},
  {path: '/poll', component: PollListComponent},
  {path: '/',        component: PollListComponent}
])
export class AppComponent {
    constructor(public http: Http,private router: Router) {
        
    }
}
github simpulton / angular2-website-routes / app / app.component.ts View on Github external
import {Component} from '@angular/core';
import {Routes, ROUTER_DIRECTIVES} from '@angular/router';
import {AboutComponent} from './about/about.component';
import {ExperimentsComponent} from './experiments/experiments.component';
import {HomeComponent} from './home/home.component';
import {StateService} from './common/state.service';
import {ExperimentsService} from './common/experiments.service';

@Component({
  selector: 'app',
  template: require('./app.component.html'),
  styles: [require('./app.component.css')],
  directives: [ ROUTER_DIRECTIVES ],
  providers: [StateService, ExperimentsService],
})
@Routes([
  {path: '/',            component: HomeComponent },
  {path: '/home',        component: HomeComponent },
  {path: '/about',       component: AboutComponent },
  {path: '/experiments', component: ExperimentsComponent },
  {path: '/*',           component: HomeComponent }
])
export class AppComponent {}
github Farata / angular2typescript / chapter3 / basic_routing / app / main_param.ts View on Github external
import {HomeComponent} from './components/home';
import {ProductDetailComponentParam} from "./components/product_param";

import {bootstrap} from '@angular/platform-browser-dynamic';
import {Component, provide} from '@angular/core';
import {LocationStrategy, HashLocationStrategy} from '@angular/common';
import {Routes, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';

@Component({
    selector: 'basic-routing',
    template: `<a>Home</a>
              <a>Product Details</a>
              `,
    directives: [ ROUTER_DIRECTIVES]
})
@Routes([
    {path: '/', component: HomeComponent},
    {path: '/product/:id', component: ProductDetailComponentParam }
])
class RootComponent{}

bootstrap(RootComponent, [ROUTER_PROVIDERS, provide(LocationStrategy, {useClass: HashLocationStrategy})]);
github Farata / angular2typescript / chapter3_router_v2 / samples / src / main-matrix-params-advanced.ts View on Github external
}
}

@Component({
  selector: 'product-list',
  directives: [ROUTER_DIRECTIVES],
  styles: ['.list {background-color: yellow}'],
  template: `
    <div class="list">
      <h1>Product List</h1>
      <pre>Category: {{category}}<br>Title:    {{title}}</pre>
      <a>Five star reviews</a>
      
    </div>`
})
@Routes([
  { path: 'reviews', component: ProductReviewsComponent }
])
class ProductListComponent implements OnActivate {
  category: string;
  title: string;

  routerOnActivate(currentSegment: RouteSegment) {
    this.category = currentSegment.getParam('category');
    this.title = currentSegment.getParam('title');
  }
}

@Component({
  selector: 'basic-routing',
  directives: [ROUTER_DIRECTIVES],
  template: `
github danielschmitz / angular2-codes / 08 / blog / app / app.component.ts View on Github external
import {Component} from '@angular/core';
import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Routes} from '@angular/router'
import {HomeComponent,LoginComponent,AddPostComponent} from './component'
import {User} from './model/user'
import {LoginService} from './service/login'

@Component({
    selector: 'my-app',
    providers: [ROUTER_PROVIDERS],
    directives: [ROUTER_DIRECTIVES],
    templateUrl:'appComponent.html',
  
})
@Routes([
    { path: '/', component: HomeComponent },
    { path: '/Login',  component: LoginComponent },
    { path: '/Addpost', component: AddPostComponent }    
])
export class AppComponent {
    
    public title: string = "Blog";
    constructor(private _loginService:LoginService){
           
    }
    
}