I am having a little trouble with binding a dynamic function to a click event. Please see below:-
File 1
<title-bar [actions]='[{title: "Create A New Plan", link: "hello"}]' ></title-bar>
File 2
<div class="actions" *ngIf="actions">
<a *ngFor="let action of actions" class="ui primary button" (click)="[action.link]()">{{action.title}}</a>
</div>
All of the code is working perfectly apart from when I am binding the action.link in the (click).
If I create the following button:-
<button (click)="hello()"></button>
It calls the hello() function as it should. but for some reason I am not able to get this to work dynamically.
Does anybody have a simple solution to this I may have over looked?
The function is calling a simple alert just for testing:-
public hello() {
alert('test');
}
II have attempted to change the click event to the following but with no joy:-
(click)="action.link"
(click)="[action.link]()"
(click)="this[action.link]()"
I get the following errors respectively:-
No error, but not function called
inline template:3:2 caused by: ["hello"] is not a function
inline template:3:2 caused by: self.parentView.parentView.context[self.context.$implicit.link] is not a function
Any help with a push in the right direction will be very much appreciated.