드롭 다운 목록의 값을 설정하는 데 문제가 있습니다. 여기에 내 코드를 붙여 넣습니다.목록 및 값 드롭 다운
HTML 코드 : 내 express.js이 설정되어 마침내 여기
$scope.studentname = ["abc","pqr","xyz"];
$scope.save = function(){
$http.post('/savemarks', $scope.setmarks).success(function(data){
console.log("posted data successfully");
console.log(JSON.stringify(data));
}).error(function(data){
console.error("Error posting data");
})
}
그리고 다음은
<form ng-submit="save()">
<table style=" table-layout: fixed;" class="table">
<thead>
<tr>
<th>Section</th>
<th>Names</th>
<th>Marks</th>
</tr>
</thead>
<tbody>
<tr>
<td>5th class</td>
<td>
<select id="5thclass" ng-model="setmarks.5thclass" ng-options="val for val in studentname">
<option ng-init="setmarks.5thclass=studentname[0]" selected="selected"></option>
</select>
</td>
<td>
<input type="number" name="5thclass" ng-model="setmarks.marks.5thclass"/>
</td>
</tr>
</tbody>
</table>
<div class="sub" class="btn-group">
<input id="savebutton" type="submit" ng-click="Submit" value="Save" class="btn btn-primary">
</div><br />
</form>
내 AngularJS와 코드입니다. 양식 세부 정보를 파일에 저장합니다.
app.post('/savemarks',urlencodedParser,function(req,res){
fs.appendFile(writecost_file,JSON.stringify(req.body,null,1),function(err){
if(err){
console.log(err);
}else{
console.log("File saved");
}
});
});
출력은 JSON의 형태 :
{"5thclass":"abc","marks":{"5thclass":66}}
내가 출력 형식이어야합니다.
{"5thclass":"abc","marks":{"abc":66}}
마크 란에서 나는 클래스 이름 대신 학생 이름을 원합니다. 아무도 나를 도울 수 있습니까? 감사 .
감사합니다. 문제가 해결되었습니다. – naik3
위대한, 그것을 듣고 행복합니다. –