我的测试页面使用 beta.0 进行路由,但没有使用 beta.1。Atom-typscript 在页面加载时没有显示错误并且控制台没有错误,但是锚选择没有链接颜色 - 它们有文本颜色。单击锚点时,会出现此控制台错误。
ERROR CONTEXT: angular2.min.js:17:5927
13:21:22.030 Object { element: <a>, componentElement: <residence-app>, context: Object, locals: Object, injector: Object } angular2.min.js:17:5927
13:21:22.038 Error: EXCEPTION: Error during evaluation of "click"
ORIGINAL EXCEPTION: TypeError: this.directive_0_0.onClick is not a function
相关代码为:
app.ts (boot.ts 文件对所有组件进行引导)
//various imports
@Component({
selector: 'residence-app',
templateUrl: "angular2-oPost/src/components/navigation/headerFooter.html",
styleUrls: [ "angular2-oPost/src/commonStyles/headerFooter.css" ],
directives: [ ROUTER_DIRECTIVES, Home, PostApartment4Rent ]
@RouteConfig( [
new Route({ path: "/home", name: "Home", component: Home, useAsDefault: true }),
new Route({ path: "/postApartment4Rent ", name: "PostApartment4Rent", component: PostApartment4Rent })
] )
export class HeaderFooter { }
headerFooter.html
<header>
<!-- several divs-->
<a [routerLink]="['/Home']">Home</a>
<a [routerLink]="['/PostApartment4Rent']">Rent Apartment in hF</a>
</header>
<div class="partialPage">
<router-outlet></router-outlet>
</div>
<footer>
<!-- several divs-->
</footer>
主页.ts
@Component({
selector : "home",
styleUrls: [ "angular2-oPost/src/commonStyles/headerFooter.css" ],
templateUrl: "angular2-oPost/src/components/navigation/home.html",
directives: [ RouterLink ]
})
export class Home { }
postApartment4Rent.ts - 与 home.ts 相同,除了 @Component 和 class 语句中的选择器
解决方法是什么?发行说明没有提到路由器的重大更改。