I've created a custom directive appFade
, and am trying to add it to a child component as below. When doing so, I get "Parser Error: Got interpolation ({{}}) where expression was expected." The culprit is: [appFade]="{{true}}"
. I saw on Got interpolation ({{}}) where expression was expected that:
{{}} never goes together with [prop]="..." or (event)="..."
I tried getting rid of the interpolation and/or the [ ]
and many other permutations, but nothing works so far. Any ideas how I should fix my code?
Custom Directive "appFade":
import { Directive, Renderer, ElementRef, HostListener } from '@angular/core';
import { NgModuleResolver } from '@angular/compiler';
@Directive({
selector: '[appFade]'
})
export class FadeDirective {
constructor(private renderer : Renderer, private el : ElementRef) {
el.nativeElement.style.opacity= '.6';
el.nativeElement.style.transition = '.4s opacity'
}
@HostListener('mouseover') mouseover() {
this.renderer.setElementStyle(this.el.nativeElement, 'opacity', '1');
}
@HostListener('mouseout') mouseout() {
this.renderer.setElementStyle(this.el.nativeElement, 'opacity', '.6');
}
}
HTML file:
<app-repository-display [searchResults]="searchResults.repositories" [appFade]="{{true}}"></app-repository-display>