I'm creating a web application using Aurelia. ( http://aurelia.io/ ). I need to pass function parameters from HTML view to controller. Here's my HTML code.
<table class="table table-bordered">
<thead>
<tr>
<th>Full Name</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr repeat.for="user of users">
<td>
${user.fullname}
<div id="${user.oid}" class="collapse">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
</td>
<td>
<a href="#${user.oid}" click.delegate="select($user)" data-toggle="collapse"
class="btn btn-primary btn-xs">View</a>
</td>
</tr>
</tbody>
</table>
In this code, you can see this function with parameter of '$user'.
click.delegate="select($user)"
I need to access this user object from the controller as I have done in the controller. But it's not working and get me undefined error.
select(user) {
console.log(user);
}
When I print the user object, it's undefined. So can you tell me how to fix this please ? If I can't pass the whole user object, tell me a way to pass one single value like 'user.fullname'. That would also be fine.
Thanks :)
进行以下更改:
click.delegate="select(user)"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.