Answer the question
In order to leave comments, you need to log in
Why does routing work incorrectly in Angular 2?
Good day to all! I would like to clarify one question from knowledgeable people: why routing in Angular 2 does not work for me as intended:
Application root ( app.component.ts ):
import {Component} from 'angular2/core';
import {RouteConfig, Router, ROUTER_DIRECTIVES} from 'angular2/router';
import {Home} from './home/home.component';
import {AdminRoot} from './admin/adminRoot.component';
@Component({
selector: 'app',
pipes: [],
providers: [],
directives: [ROUTER_DIRECTIVES],
styles: [''],
template: require('./app.html')
})
@RouteConfig([
{path: '/', name: 'Index', component: Home},
{path: '/home', name: 'Home', component: Home, useAsDefault: true},
{
path: '/admin',
name: 'AdminRoot',
loader: () => require('es6-promise!./admin/adminRoot.component')('AdminRoot')
}])
export class App {
constructor() { }
}
Answer the question
In order to leave comments, you need to log in
Do it the right way, through /admin/... . If there are difficulties, then read this answer from SO.
There is an example in the Angular documentation itself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question