그래서 저는 팀을 위해 만들어진 웹 응용 프로그램을 만들고 있습니다. 이미 로그인 및 가입 페이지가 구현되어 있고 내 그룹의 구성원 중 일부가 서버 (node.js와 익스프레스 프레임 워크) 및 데이터베이스 측에서 작업하고 있으며 프론트 엔드/클라이언트 측에서 작업하고 있습니다. angularjs 프레임 워크를 사용합니다. 기본적으로 팀 이름의 배열을 가져 오는 angularjs의 "팀 목록 페이지"를 만들 필요가 있습니다 (로그인 한 사람이 여러 가지 소프트웨어 개발 그룹을 가질 수 있습니다).AngularJS를 사용하여 서버 측에서 배열을 얻는 방법은 무엇입니까?
team_list.html의 서버 측은 아직 구현되지 않았지만 클라이언트 측과 완료 될 것입니다.
내 문제는 : 어떻게 angularjs에서 서버/데이터베이스 측면에서 배열을 가져올 모르겠다. 어떻게 든 ng-repeat 지시어와 GET 메서드를 사용해야한다는 것을 알고 있지만 어떻게해야하는지 정확히 모르겠습니다. 특히 배열을 사용하여이를 수행하는 방법. 알고하는 $http docs을 보라
$http.get('url').then(function (response) {
// Success case
$scope.teamList = response.data;
}, function (error) {
// Error case
});
:
var page = angular.module('teamListPage', []);
page.controller('listController', function($scope, $http) {
console.log("inside the controller");
//need to figure out how to pass info to server to retrieve the correct page
$scope.submit = function() {
console.log("inside the login function");
console.log()
}
$scope.enterTeamPage = function() {};
}
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
title>Team List</title>
</head>
<body>
<h1>
Welcome to Your Team Pages!
</h1>
<div ng-controller="listController">
<form id="Teams" ng-app="teamListPage">
<fieldset>
<legend>Your Teams</legend>
<ul>
<div ng-repeat"x in teamList">
<td>{{x.Name}}</td>
<p>
<input type="button" id="enter" name="enter" value="Enter Home Page" />
</p>
</div>
</ul>
</fieldset>
</form>
</div>
<p>
<input type="button" id="Create" name="Create" value="Create New Team" />
</p>
</body>
</html>
'$ http.get'은 어떨까요? 참조하십시오 : http://stackoverflow.com/questions/18477711/force-angularjs-service-to-return-data-before-loading-controller – jmunsch