여기에 "$ scope.getCourse = 'adobe'"값을 서버에 전달하여 해당 코스 세부 정보를 반환 할 수 있도록합니다. 응답 데이터에서 ng-repeat를 사용하여 나열하십시오. 하지만 아래 코드는 servelet url과 함께 "$ scope.getCourse"를 삽입 할 때 실패합니다.
{ "MainTopic": "Adobe", "RunningTime": "6h11min", "Description": "Course Description comes here", "CourseOutline": [ { "Lessons" : "Lesson 1" , "Title" : "Introduction1" , "Duration" : "31m 27s"}, { "Lessons" : "Lesson 2" , "Title" : "Introduction2" , "Duration" : "56m 05s"}, ] }
저 위의 senario을 달성하는 방법을 알려 주시기 바랍니다 servelet에서
var courseApp = angular.module('courseApp', []); courseApp.controller('courseCtrl', ['$scope', '$http', function($scope, $http){ //$scope.getCourse = 'adobe'; //need to pass this value to the server; $http.post('javaServerlet', $scope.getCourse).success(function(data){ $scope.result = data.MainTopic; $scope.lessons = data.CourseOutline; }) }])
JSON 형식, 나는 AngularJS와 아주 새로운 해요.
에서 서버에 얻을 것이다 어떻게 코드가 실패 하는가? 콘솔 오류가 발생합니까? 성공 함수가 실행되지 않습니까? – JeffryHouser