0
이 코드에서는 서버에서 응답을 성공적으로 받고 있지만 ng-model에 표시 할 값을 가져올 수 없습니다.AngularJS : 내 모델이 업데이트되지 않는 이유는 무엇입니까?
개체에 액세스하는 데 모든 종류의 방법을 시도했지만 Object.attribute 구문이 정확하다고 생각했습니다. 나는 틀린가?
<html ng-app="notesApp">
<head><title>Notes App</title></head>
<body ng-controller="MainCtrl as ctrl">
<div>
<h2>Job Inspections?</h2>
<div class="input-group">
<label>Inspection ID</label>
<input type="text" ng-model="ctrl.list.id">
</div>
<div class="input-group">
<label>Inspection ID2</label>
<input type="text" ng-bind="ctrl.list.id">
</div>
<div class=
<div class="input-group">
<label>Job ID</label>
<input type="text" ng-model="ctrl.list.job_id">
</div>
<div class="input-group">
<label>Inspection Type</label>
<input type="text" ng-model="ctrl.inspection_type">
</div>
<div class="input-group">
<label>Bodywork</label>
<input type="checkbox"
ng-checked="ctrl.bodywork === 1">
</div>
<div class="input-group">
<label>Lighting</label>
<input type="checkbox"
ng-checked="ctrl.lighting === 'YES'">
</div>
</div>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js">
</script>
<script type="text/javascript">
angular.module('notesApp', [])
.controller('MainCtrl', ['ItemService', function(ItemService) {
var self = this;
self.list = function() {
return ItemService.list().then(function(data) {
console.log(data);
return data;
})
}();
//console.log(self.list);
self.add = function() {
ItemService.add({
id: self.list().length + 1,
label: 'Item ' + self.list().length
});
};
}])
.factory('ItemService', ['$http', function($http) {
return {
list: function() {
return $http.get('/api_job_inspections/1/edit').then(function(response) {
return response.data;
}, function(errResponse) {
console.error('Error while fetching notes');
});
},
add: function(item) {
self.items.push(item);
}
};
}]);
</script>
</body>
</html>
평소와 같이 사전에 알려 주시기 바랍니다.
정말 대단합니다. 도와 줘서 고마워요! –