【发布时间】:2015-11-22 12:53:03
【问题描述】:
我尝试创建一个简单的 angular2 组件,但在将指令绑定到本机 DOM 元素时出现错误。
例如:
/// <reference path="../../typings/_custom.d.ts" />
import { Component, View } from 'angular2/angular2';
import { RouterLink } from 'angular2/router';
@Component({
selector: 'my-component',
directives: [RouterLink]
})
@View({
template: `
<a [router-link]="['/page']">test</a>
`
})
export class MyComponent { }
=> 无法绑定到“routerLink”,因为它不是“”元素的已知属性,并且没有具有相应属性的匹配指令。
我做错了什么?
【问题讨论】:
-
嘿@tzi
directives属性必须放在View注释中。 -
谢谢@EricMartinez。 -_-\/
标签: angular