【发布时间】:2015-08-21 15:33:58
【问题描述】:
我正在尝试调用 REST API,将两个参数传递给另一个视图和另一个控制器。
语法是/api/:id/something/:id2/something。
在接收端,我有一个工厂来处理调用并将其传递给新页面的控制器。
这是我的观点:
<div>
<table class="table table-striped">
<thead>
<th style="padding-left: 20px;">ACN Name</th>
<th>Product Name</th>
<th>ContractNumber</th>
<th>Start Date</th>
<th>End Date</th>
<th></th>
<tr ng-repeat="row in acns">
<td style="padding-left: 20px;"><a href="" ng-click="viewOrgList(ACNID)">{{row.ACNName}}</a></td>
<td>{{row.ProductName}}</td>
<td>{{row.ContractNumber}}</td>
<td>{{row.ContractStartDate}}</td>
<td>{{row.ContractEndDate}}</td>
<td><a href="" ng-click="remove(row)"><i class="fa fa-times" style="font-size:1.5em;"></i></a></td>
</tr>
</table>
</div>
此视图的控制器如下所示:
app.controller('acnController', ['$scope','$location', '$routeParams',
function ($scope, $location, $routeParams) {
//Passing acnId to networkOrg template to display.
$scope.viewOrgList = function (acnId) {
$location.path('/NetworkOrgs' + acnId);
}
}]);
在 /NetworkOrgs 模板的控制器上,它看起来像这样:
app.controller('orgController', ['$scope', '$routeParams','$location', 'orgFactory', function ($scope, $routeParams, $locatoin, orgFactory) {
//Capture routeParam id and display associated orgs
$scope.org = $routeParams.acnId;
}]);
app.factory('orgFactory', ['$resource','$routeParams', function ($resource, $routeParams) {
return $resource("http://localhost:16047/api/acn/:acnId/networkOrgs", { acnId: $routeParams.acnId }, {
getOrgs: { method: 'GET', params: { acnId: '@acnId'} }
})
}])
这对我不起作用,我得到一个“错误的论点”结果。
任何帮助都会很棒!
【问题讨论】:
标签: javascript angularjs asynchronous angularjs-resource