I try to create a simple angular2 component, and I have an error when binding directive to a native DOM element.
For example:
/// <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 { }
=> Can't bind to 'routerLink' since it isn't a known property of the '<a>' element and there are no matching directives with a corresponding property.
What did I do wrong?
Here is the right code:
import { Component } from 'angular2/core';
import { RouterLink } from 'angular2/router';
@Component({
selector: 'my-component',
directives: [RouterLink],
template: `
<a [routerLink]="['/page']">test</a>
`
})
export class MyComponent { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With