AngularJS Spring mvc @RequestParam
Ich bin Neuling in Angularjs,im folgenden Frühjahr controller-Objekt aus Datenbank-id ich will
Holen Sie sich Dieses id @RequestParam mit AngularJs ,ich versuche den folgenden code, bekomme aber diesen Fehler
"Fehler: die id ist nicht definiert
.findOne@ localhost:8080/myapp/scripts/services.js:126:79
$Umfang.findOne@ localhost:8080/myapp/scripts/Controller.js:280:4
Spring MVC-Controller
@RequestMapping(value = "/rest/chartConfigs/getById",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@RolesAllowed(AuthoritiesConstants.ADMIN)
public ChartConfigs findOne(@RequestParam(value = "id") Integer id) {
System.out.println(chartConfigService.getOne(id));
return chartConfigService.getOne(id);
}
AngularJS-Service
myappApp.factory('ChartConfigService', function ($http) {
return {
findOne: function() {
var promise = $http.get('app/rest/chartConfigs/getById',{params: {id: id}}).
then(function (response) {
return response.data;
});
return promise;
}
}
});
AngularJS Controller
myappApp.controller('ChartConfigController', function ($scope, ChartConfigService) {
$scope.findOne= function() {
ChartConfigService.findOne($scope.id).then(function(obj) {
$scope.message=obj;
console.log(obj.type);
});
};
});
Html-Seite
<input ng-model="id" ng-change="findOne()" required>
InformationsquelleAutor ali ibrahim | 2015-01-05
Du musst angemeldet sein, um einen Kommentar abzugeben.
Haben Sie vergessen, pass-id findOne als Funktions-parameter:
InformationsquelleAutor udalmik