0
<select>
タグにdata-ng-change='getSubjectsClasswise(classBean.class_id);'
を追加しましたが、被験者は件名<select>
タグにロードされていません。
問題は発生していないものの、問題なく表示されます。お手伝いをしてください。ng-change not working、ng-change後にデータがロードされない
JSP:
<div data-ng-controller='ChapterController'>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3">Select Class * :</label>
<div class="col-sm-8">
<div class="col-sm-6">
<select data-ng-model='classBean.class_id' data-ng-change='getSubjectsClasswise(classBean.class_id);' class="form-control" name='stdClass' required>
<option value="">--SELECT--</option>
<option data-ng-repeat='c in clss' value="{{ c.class_id}}">{{ c.class_name}}</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">Select Subject * :</label>
<div class="col-sm-8">
<div class="col-sm-6">
<select data-ng-model='sid' class="form-control" required>
<option value="">--SELECT--</option>
<option data-ng-repeat='s in subss' value="{{ s.sid}}">{{ s.subject_name}}</option>
</select>
</div>
</div>
</div>
<div class="btn-right">
<button type="submit" value="Register" class="btn btn-primary">Register</button>
</div>
</form>
JSコントローラー:
'use strict';
var app = angular.module("CareerTurn");
app.controller('ChapterController', function($scope, $http, $location, $window, AdminService) {
getClasses();
function getClasses() {
$http({
method : 'GET',
url : 'http://localhost:8015/CareerTurn/adm/getClasses.do'
}).then(function successCallback(response) {
$scope.clss = response.data;
}, function errorCallback(response) {
console.log(response.statusText);
});
}
$scope.getSubjectsClasswise = function(class_id) {
alert(class_id);
var URL ='http://localhost:8015/CareerTurn/adm/getClasswiseSubjects.do';
$http.post(URL,class_id).success(function(response){
$scope.subss = response.data;
}).error(function(reponse){
alert('error');
});
}
})。
Javaのコントローラー:
@RequestMapping(value="/getClasswiseSubjects.do", method=RequestMethod.POST)
public @ResponseBody List<SubjectBean> getClasswiseSubjects(@RequestBody int class_ids) {
return getAdminService().getClasswiseSubjects(class_ids);
}
@RequestMapping(value="/getClasses.do", method=RequestMethod.GET)
public List<ClassBean> getClasses() {
return getAdminService().getClasses();
}
DaoImpl:
@Override
public List<ClassBean> getClasses() {
try{
String sql="from ClassBean";
query = em.createQuery(sql);
return query.getResultList();
}catch(Exception ex){
ex.printStackTrace();
}
return null;
}
@Override
public List<SubjectBean> getClasswiseSubjects(int class_id) {
try{
query = em.createQuery("from SubjectBean sb where sb.classBean.class_id=:class_id");
query.setParameter("class_id", class_id);
List<SubjectBean> subs = query.getResultList();
return subs;
}catch(Exception ex){
ex.printStackTrace();
}
return null;
}
コンソール:
Hibernate: select classbean0_.class_id as class1_1_, classbean0_.class_createdate as class2_1_, classbean0_.class_createdby as class3_1_, classbean0_.class_name as class4_1_ from exam_class classbean0_
Hibernate: select subjectbea0_.sid as sid26_, subjectbea0_.class_id as class6_26_, subjectbea0_.subject_code as subject2_26_, subjectbea0_.subject_createdate as subject3_26_, subjectbea0_.subject_createdby as subject4_26_, subjectbea0_.subject_name as subject5_26_ from subjects_tbl subjectbea0_ where subjectbea0_.class_id=?
はそんなにuの感謝、uは私の一日行われません。あなたにもう一度お礼を言います。 –
@Chetanは答えを –
@BOSSありがとうございます。 –