以下是我的文件的链接。我无法使用$http
生成的现有网址生成网址,使用$parent.$index
和$index
作为路由ID,请帮助:Plunker
我已将相同类型的功能应用于其工作的另一个应用程序Plunker
更新loadSingleMatch()
内的url
时出现$http
函数错误
错误图片: -
app.controller("selfController", ['$http', '$routeParams',
function($http, $routeParams) {
//create a context
var main = this;
this.parentId = $routeParams.parent;
this.childId = $routeParams.child;
console.log(this.parentId);
console.log(this.childId);
this.urlOne = "https://raw.githubusercontent.com/openfootball/football.json/master/2015-16/en.1.json";
this.urlTwo = "https://raw.githubusercontent.com/openfootball/football.json/master/2016-17/en.1.json";
this.loadSingleMatch = function() {
$http({
method: 'GET',
url: main.urlOne + '/' + main.parentId + '/' + main.childId
}).then(function successCallback(response) {
main.matchData = response.data.rounds[main.parentId].matches[main.childId];
console.log(main.matchData);
}, function errorCallback(response) {
console.log(response);
});
}
}
]);
答案 0 :(得分:0)
a标签应位于第二个ng-repeat中:
<div class="w3-row w3-hover-shadow w3-hover-border-black w3-border w3-white w3-padding-16" ng-repeat="x in matchDay.matches">
<a ng-href="#/indiTeam/{{$parent.$index}}/{{$index}}" >
<div class="w3-small">
<div class="w3-col s6 ">
{{x.team1.code}} vs {{x.team2.code}}
</div>
<div class="w3-col s6">
<div class="w3-padding-small">
{{ x.date | date: 'shortDate'}}
({{$parent.$index}} {{$index}})
</div>
</div>
</div>
</div>
</a>
</div>
见修改过的plunker: https://plnkr.co/edit/PeqUHIZVC0HsqdjLkdOo?p=preview
答案 1 :(得分:0)
终于找到了我的问题的答案
不应更改$ http内的url
,只需更改其内部的响应
url: main.urlOne
是按预期购买输出的更改