I have a working PLNKR written with angular version2.
It's a simple timer where the component has a reference to the directive which contains the logic :
@Component({
selector: 'my-app',
template: `
<div>
<div class="timer" *simpleTimer="#timer=timerApi"> <-- see here
<div class="time">{{ timer.getTime() }}</div>
...
</div>
`
and in the directive itself - it sets the value for timerApi
via :
view.setLocal('timerApi', api);
The directive doesn't use exportAs
:
@Directive({
selector: '[simpleTimer]'
})
I want to convert it to Angular 4. but some features doesn't work.
For example , the following code : *simpleTimer="#timer=timerApi"
yields :
Parser Error: Unexpected token # at column 1 in [#timer=timerApi]
Also this method view.setLocal
doesn't exist anymore.
Question:
How can I reference the directive from the component ? ( so i'll have all its methods)
I've added the exportAs
to the directive and it still doesn't work.