I want to pass in the delay of a component's animation from the html eg:
html:
<circles[delay]="'10000ms'"></circles>
ts:
@Component({
selector: 'circles',
templateUrl: 'app/landing-page/subcomponents/circles.component.html',
styleUrls: ['app/landing-page/subcomponents/circles.component.css'],
animations: [
trigger('flyIn', [
state('in', style({ transform: 'translateY(0)', opacity: 1 })),
transition('void => *', [
style({ transform: 'translateY(-100%)', opacity: 0 }),
animate("1000ms" + this.delay)
])
])
]
})
export class CirclesComponent {
@Input() private delay: string;
However when I do that it gives this error:
(SystemJS) Cannot read property 'delay' of undefined(…)
How can I pass in the delay to the component in html without causing this error?
I might be a little bit late but this may help someone else.
Load it into your component:
Then you can use it in your template like this and control the delay for each animation:
Don´t forget to pass the a value else it will not work. I hope this helps!
You are trying to use
this
inthis.delay
to refer to the current class, but you are doing this outside the class. Note that@Component()
function is executed before you declareclass CirclesComponent
This isn't very elegant but you could set a property on the
window
object when you want to set the delayThen in your animation, you could access it with `window.custom? window.custom.delay :