29
저는 AngularJS에 익숙하지 않으며 문제를 해결하는 데 문제가 있습니다. 비슷한 질문이 stackoverflow에 있었지만 도움이되지 않았습니다. 기본적으로 ng-click으로 업데이트되는 양식이 있지만 한 번 텍스트 상자에 텍스트를 입력하면 해당 텍스트 상자가 더 이상 업데이트되지 않습니다. 텍스트 입력 후 ng-model이 더 이상 업데이트되지 않습니다.
이
내 HTMLEdit Course:
<li ng-repeat="course in courses">
<p>
<a ng-click="Edit_Course(course.id)">{{course.course_name}}</a>
</p>
</li>
<div ng-show="showedit == 1">
<form novalidate ng-submit="edit_course()" class="simple-form">
<label for="form_course_name">Course</label>
<input type="text" id="form_course_name" ng-model="edit_course_name">
<label for="form_par">Par</label>
<input type="text" id="form_par" ng-model="edit_course_par">
<label for="form_course_location">Course Location</label>
<input type="text" id="form_course_location" ng-model="edit_course_location">
<input type="submit" id="submit" value="Edit Course" />
</form>
</div>
사람이 귀하의 링크가 로그인이 필요한
$scope.Edit_Course = function (id) {
var course = {
'course_id' : id
};
$http({method: "POST", url: "http://www.dgcharts.com/editcourse", data: course})
.success(function(data, status, headers, config){
thecourse = data["course"];
$scope.edit_course_name = thecourse.course_name;
$scope.edit_course_par = thecourse.par;
$scope.edit_course_location = thecourse.course_location;
$scope.edit_course_id = thecourse.id;
$scope.showedit = 1;
})
}
대단히 감사합니다. 약 60 초 후에 고쳐 주셔서 감사합니다. 이 프로젝트를 계속하기 전에 스코프를 확실히 읽을 것입니다. 분명히 완전히 이해하지 못하기 때문입니다. – EvWill
@Ev 여기 왜 프리미티브와 함께 작동하지 않는 좋은 설명이 있습니까? https://github.com/angular/angular.js/wiki/Understanding-Scopes – Mirko
한 달 이상 잘못 사용했습니다. 정말 고마워요. 이것이 올바른 방법이 아니라면, Angular는 devs가 코드를 그렇게 쓰는 것을 허용해서는 안됩니다. 이 문제는 완전한 2 박 동안 나를 두려워했다. : D –