Angular:升级到4.0.0后进行编译时出错

时间:2017-03-27 17:52:18

标签: angularjs templates

我刚刚将我的应用升级到Angular 4.0.0 final。

升级后(并没有改变任何其他内容),我收到一堆错误告诉我Supplied parameters do not match any signature of call target.

错误消息指向我的模板中的纯HTML标记,而不是任何“调用目标”#9;我能辨认出来。

问题出在此文件中:https://github.com/canonn-science/CanonnApi/blob/feature/site-editor/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html

以下是错误消息: ERROR in ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (15,9): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (15,5): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (25,7): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (30,84): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (31,83): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (35,7): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (40,84): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (41,90): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (42,84): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (46,7): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (51,84): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (52,88): Supplied parameters do not match any signature of call target.
ng:///D:/Dev/CanonnApi/CanonnApi.Frontend/src/app/components/main-sidebar/main-sidebar.component.html (53,83): Supplied parameters do not match any signature of call target.

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您收到此消息是因为router.isActive类上的Router需要多个参数。

根据docs

  

isActive(url:string | UrlTree,exact:boolean):boolean

isActive获取url字符串AND是否将其评估为完全匹配。

如果我可以建议另一种方法来完成切换活动'不使用ngClass而不是

的类
<li [ngClass]="{ 'active': router.isActive('/basedata/codex') }">

built in directives来处理这类事情:

<li routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}">

希望这有帮助。