我刚刚将我的应用升级到Angular 4.0.0 final。
升级后(并没有改变任何其他内容),我收到一堆错误告诉我Supplied parameters do not match any signature of call target.
错误消息指向我的模板中的纯HTML标记,而不是任何“调用目标”#9;我能辨认出来。
以下是错误消息:
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.
我错过了什么?
答案 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}">
希望这有帮助。