假设我有一个记录索引页,如下所示:
<tr ng-repeat="record in records">
<td>{{ record.name }}</td>
<td>
<a href="" ng-click="showRecord(record);">View</a>
<a href="" ng-click="deleteRecord(record);">Delete</a>
</td>
</tr>
还有一个控制器,就像这样:
app.controller('RecordIndexCtrl', function($scope, RecordResource) {
$scope.records = RecordResource.query();
$scope.deleteRecord = function(record) {
// Code to delete record, set flash, change route etc
}
});
到目前为止,这很棒。但是如果我想在View页面上包含Delete链接怎么办?或者我的应用程序中除控制器范围之外的任何其他位置?