Ben aşağıdaki durumlarda bir angularjs uygulamasının bir parçası olarak:AngularJS isteği isteğinin yapısını nasıl değiştirebilirim?
controller('StagesCtrl', function($scope,$http) {
$http.get("http://localhost/apistages")
.then(function(response) {
$scope.stages = response.data;
});
})
.controller('StageCtrl', function($scope, $http, $stateParams) {
$http({
method: 'GET',
url: 'http://localhost/apistage/',
params: {stageId: $stateParams.stageId}
}).then(function successCallback(response) {
$scope.stage = response.data;
}, function errorCallback(response) {
});
});
aşamaları liste iyi çalışıyor, ama sahne denetleyicisi sorgu http://localhost/apistage/?stageId=43 erişmeye çalıştığında:
.state('app.stages', {
url: '/stages',
views: {
'menuContent': {
templateUrl: 'templates/stages.html',
controller: 'StagesCtrl'
}
}
})
.state('app.stage', {
url: '/stages/:stageId',
views: {
'menuContent': {
templateUrl: 'templates/stage.html',
controller: 'StageCtrl'
}
}
ilişkili kontrolörlerdir hangi bir 500 (Dahili Sunucu Hatası) ile sonuçlanır.
Kullanmam gereken URL biçimi http://localhost/apistage/43'dur. Bu URL'yi almak için sorguyu nasıl ayarlayabilirim?
Bunu denemiştim, ama geç akşamlar ve bir süredir PHP'de takılıp kalmama bana yol açtı. + yerine birleştirme için. Böyle basit bir hata. –