Adrian
Adrian

Reputation: 2012

Pass value from filter as argument for js function in angular

When I attempt to pass a value from ng-repeat into a function it seems to read the data literally from the text put in , whereas I would like to pass the values in....

            <li ng-repeat="event in filtered = (events | filter:query) | orderBy:'-event_date'" >

                <div class="event-info">
                    <strong>{{event.event_name}}</strong><br />

                </div>

                <div ng-click="prepare_edit('{{event.event_name}}')" >EDIT</div>
            </li>

Controller:

$scope.prepare_edit = function(event_name) {

        window.alert(event_name);
    }

OUTPUTS: {{event.event_name}} , whereas I would like the actual value

Upvotes: 0

Views: 25

Answers (1)

nanndoj
nanndoj

Reputation: 6770

You don't need to use braces {{}} in ng-click. If you have put "event" var inside $scope you can just use it.

 <div ng-click="prepare_edit(event.event_name)" >EDIT</div>

Here is a FIDDLE

Upvotes: 1

Related Questions