我试图从索引项目列表路由到显示该项目的详细视图的页面。AngularJS从索引到详细页面的动态路由
在我的索引视图中,我有一个遍历数据库中保存的所有项目的表。
有行动列下一个按钮,将带我去事件/使用显示路线ng-click="go('events/show')"
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Title</th>
<th class="col-md-2">Actions</th>
</tr>
</thead>
<tbody>
<tr scope="row" ng-repeat="event in events | reverse | filter:filterByUID">
<td>{{event.title}}</td>
<td class="col-md-2">
<div class="btn-group" role="group" aria-label="actions">
<button class="btn btn-primary" ng-click="go('events/show')">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
</button>
<button class="btn btn-primary" ng-click="events.$remove(event)">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
在我的控制,我有:
$scope.go = function (path) {
$location.path(path);
};
在我的routes.js我有:
.whenAuthenticated('/events/show', {
templateUrl: 'views/eventShow.html',
controller: 'eventShowCtrl'
})
一切工作到目前为止。
但是,我不清楚的是如何将事件ID传递到eventShow.html页面,所以我知道从索引列表中单击了哪个项目,以便我可以显示详细信息?
我的火力数据库看起来是这样的:
硕士细节例如:https://jsfiddle.net/katowulf/m6spubtp/ – Kato