Angular 2 Router error, Route config should contain exactly one “component”, “loader”, or “redirectTo” property

后端 未结 8 1783
南笙
南笙 2021-01-18 05:35

This is my setup:

import {bootstrap} from \'angular2/platform/browser\';
import {Component} from \'angular2/core\';
import {LocationStrategy, APP_BASE_HREF,          


        
8条回答
  •  -上瘾入骨i
    2021-01-18 06:29

    Same error i had faced but i have solved this as below:

    when i write the code like this

    { path: '/formDemo', Component: FormDemo, name: "FormDemo"},
    

    it shows throws the same error you faced but after searching i have found error is in my Component attribute of routeConfig i.e angular2 thinks we have write a Component annotation in the routeConfig but it accept only exactly one loader,component,redirectto (URL) property. but we have write something else , so when i changed Component with component code is working fine.

    { path: '/formDemo', component: FormDemo, name: "FormDemo"},
    

    above line make my code working. It may not help to solve your problem because you have already write component insted of Component but i have posted this for others may be it will help to someone else thanks

提交回复
热议问题