I'm writing an application in node.js/angular and wants to get the user id to my index.html file but have been unable to using:
<a ng-show="main.isLoggedIn" class="page-scroll" href="/mytests/{{ main.getId }}">My tests</a>
I'm quite sure this is because the token that gets decoded does not contain the user id but I haven't been able to add it.
When i needed the user id of every user in the database it worked using the following:
<tr ng-repeat="person in management.users | filter: searchFilter | limitTo: management.limit">
<td>{{ person.name }}</td>
<td>{{ person.username }}</td>
<td>{{ person.email }}</td>
<td>
<!-- Edit Button -->
<a href="/edit/{{ person._id }}">
<button type="button" ng-show="management.editAccess" class="btn btn-primary">Edit</button>
</a>
<!-- Delete Button -->
<button type="button" ng-click="management.deleteUser(person.username);" ng-show="management.deleteAccess" class="btn btn-danger">Delete</button>
</td>
</tr>
I'm not really sure if this is the best technique to get the user id which is stored on the local db or if there is a better way? If you have any suggestions on how to get it i would really appreciate it.
<td>{{ person.id }}</td>
尝试这个:
<a ng-href="/edit/{{ person._id }}" style="cursor:pointer; text-decoration:underline; color:black">Edit</a>
可能是您想要这样:
<span ng-bind="person._id"></span>
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.