moshi
moshi

Reputation: 294

angular 1.5 component to call the parent scope method

I have a html template + controller. I added there a component:

<ir irtrend="addIrTrend"></ir>

addIrTrend is a function in my controller scope. I want my component to call the addIrTrend method. I give my component the irtrend parameter like this:

bindings: {
    irtrend: '&'
}

and it has an element that has ng-click on it:

<td ng-repeat="item in items" ng-click="$ctrl.irtrend({item: item}">

As I understand, when clicking on the td element, the irtrend method which references to the parent ctrl "addIrTrend" method, should be called.

Actually nothing happens.

Any idea ?

Thanks !

Upvotes: 0

Views: 713

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136174

Actually in irtrend attribute you should be specifying method call.

<ir irtrend="addIrTrend(item)"></ir>

Also correct ng-click expression to close parenthesis $ctrl.irtrend({item: item})

Upvotes: 1

Related Questions