1

The event.id is rendered/compiled correctly in the html text but the function does not recieve it correctly. even when it shows it correctly in the source, whats going on here?

<span ng-repeat="event in [{"id":"dxczhlyvmblc","name":"4 on 4 - Pickup","venuename":"Box Hill Aqualink","numspotsleft":"<strong>Spots now open<\/strong>","day":"28","dayname":"Wednesday"}]">
    <button ng-click="toggleModal('<% event.id %>')">More detail = <% event.id %></button>
</span>

enter image description here

shopApp.controller('MainController', function($scope, $http, $q){
    $scope.toggleModal = function(eventId){
        console.log(eventId+" toggle");
    };})

Note i am using <% in stead of {{ because of the templating engine.

2 Answers 2

2

Arguments for functions in view don't use angular templating expressions.

Change to:

ng-click="toggleModal(event.id)"

You may also find it more convenient to pass the whole object in if you want to pass that object to a modal controller for example

Sign up to request clarification or add additional context in comments.

1 Comment

Excellent, was looking for this!!
1

As you want to pass the value of event.id to the toggleModal function:

<button ng-click="toggleModal(event.id)">More detail = <% event.id %></button>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.