I am using angular to build a table for me dynamically. The Expression user.User.id
needs to be listed out as an integer in each place that I use it and it works everywhere except inside a html script tag that I am using. There it throws an error in javascript. I'm sure there is a better way to do what I'm doing here, but I'm looking for a quick and simple solution to display the user id so that it can be referenced by the script tag.
Here is the code:
<table class="table" ng-hide="loading" >
<tr>
<th>Test Search Code</th>
<th>Test Current Company</th>
<th>Name</th>
<th>Email</th>
<th>Created</th>
<th></th>
</tr>
<tr ng-repeat="user in users | filter:searchText ">
<!-- THESE REFERENCES WORK FINE -->
<td>{{user.User.mapped_test_search_code}}</td>
<td>{{user.Employment[0].name}}</td>
<td>{{user.User.mapped_first_name}}</td>
<td>{{user.User.mapped_email}}</td>
<td>{{user.User.created}}</td>
<td><a href="/admin/mapped_users/edit/{{user.User.id}}"><span class="glyphicon glyphicon-pencil"></span></a></td>
<td>
<!-- THIS ONE WORKS TOO-->
<form action="{{'/admin/users/delete/' + user.User.id}}" name="post_{{user.User.id}}" id="post_{{user.User.id}}" style="display:none;" method="post" class="ng-pristine ng-valid">
<input type="hidden" name="_method" value="POST">
</form>
<!-- THIS ONE IN THE A TAG, IN THE SCRIPT ATTRIBUTE DOES NOT WORK -->
<a href="#" class="btn btn-block" onclick="if (confirm("Are you sure?")) { document[ 'post_' + user.
User.id ].submit(); } event.returnValue = false; return false;" original-title="">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</table>
ng-click="yourFunction()"
, and$scope.yourFunction = function() { /* whatever */ }
ng-click
and move the confirmation logic into a function in controller.