javascript - Cannot match any routes: "" -
app.routing.ts
import { modulewithproviders } '@angular/core'; import { routes, routermodule } '@angular/router'; import { pushcomponent } './push/push.component'; const approutes: routes = [ { path: 'push', component: pushcomponent} ]; export const approutingproviders: any[] = []; export const routing: modulewithproviders = routermodule.forroot(approutes);
app.component.ts
import { component } '@angular/core'; @component({ moduleid: module.id, selector: 'app-root', template: ` <h1>{{title}}</h1> <nav> <a [routerlink]="['/push']">push1</a> <a [routerlink]="['/push']">push2</a> </nav> <nav> <a routerlink="/push" routerlinkactive="active">push3</a> <a routerlink="/push" routerlinkactive="active">push4</a> </nav> <router-outlet></router-outlet> `, styleurls: ['app.component.css'] }) export class appcomponent { title = 'app works!'; }
push.component.ts
@component({ // selector: 'push-comp', template: // `<form (submit)="submitform()"> // <input [(ngmodel)]="element.name"/> // // <button type="submit">submit form</button> // </form> // <br> `<button (click)="getheroes()"> </button> <button (click)="saveheroes()"> push </button>`, // templateurl: 'app/html/heroes.component.html', providers: [pushservice] }) export class pushcomponent implements oninit { pushresult:pushresult; // selectedhero:hero; // addinghero = false; error:any; element:any;
but have 2 errors:
1) don't see template (2 buttons) push component
2) error cannot match routes: ''
chrome browser, don't know link ''
i have see post, have in index.html:
<head> <base href="/">
route '' default route. can add default route this-
const approutes: routes = [ { path: '', redirectto: '/push', pathmatch: 'full' }, { path: 'push', component: pushcomponent} ];
see if helps.
Comments
Post a Comment