저는 Angular를 처음 사용하기 때문에 ng-repeat에서 왜 내 개체의 첫 번째 요소 만 표시하는지 알 수 없습니다. 여기 AngularJs ng-repeat는 첫 번째 요소 만 표시합니다.
는 여기<div ng-app="GroupApp">
<div ng-controller="GroupCtrl">
<div id="divEditRow" class="row">
<div class="col-lg-8" ng-repeat="data in editGroups track by $index">
<div class="input-group input-group-lg" >
<input class="form-control input-lg" ng-model="data[$index].GroupName" />
<span class="input-group-btn">
<button type="button" class="btn btn-info btn-flat"><i class="fa fa-pencil"></i></button>
<button type="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
</span>
</div>
</div>
</div>
</div>
</div>
내 AngularJS와 내 HTML입니다 :
var app = angular
.module('GroupApp', [])
.controller('GroupCtrl', function ($scope, AddGroup, $http) {
var id_generator = function (id) {
return id + 1
}
$scope.groups = [{ 'id': 1, 'name': '' }];
// $scope.editGroups = new Array();
$http.get("/Group/GetGroups")
.success(function (data) {
$scope.editGroups = data;
});
})
나는 화면에 {{데이터}} 기록 할 때 데이터가 올바르게 B/C를 검색되는 알고 다음이 반환됩니다.
[{"CompetencyGroupID":52,"GroupName":"Quality Control","CreateDateTime":"/Date(1470675542267)/","CreateUserId":137,"ModifiedDateTime":null,"ModifiedUserID":null},{"CompetencyGroupID":53,"GroupName":"Quality","CreateDateTime":"/Date(1470675715943)/","CreateUserId":137,"ModifiedDateTime":null,"ModifiedUserID":null},{"CompetencyGroupID":54,"GroupName":"adsf","CreateDateTime":"/Date(1470681237727)/","CreateUserId":137,"ModifiedDateTime":null,"ModifiedUserID":null}]
이것은 내 C# Co 관리자
public JsonResult GetGroups()
{
List<CompetencyGroup> groupList = new List<CompetencyGroup>();
using (var db = new SSITrainingEntities())
{
//return (from g in db.CompetencyGroups
// select g).ToList();
groupList = db.CompetencyGroups.ToList();
}
var j = Json(new { Response = groupList }, JsonRequestBehavior.AllowGet);
return j;
//return groupList;
}
내가 뭘 잘못하고 있니?
NG 모델 = 데이터는이 방법 NG 모델 = "data.GroupName"에 사용해야 모델이다 "데이터 [$ 지수] .GroupName". 확인할 수 있습니까? –
네, 이전에이 방법을 시도했지만 아무 것도 반환하지 않았습니다. 심지어 첫 번째 요소 인 – Eric