Javascript 当点击一些按钮到angularjs函数时,如何提交文本框值?
我想做的是从两个文本框中提交两个单独的值。每个文本框都包含一个使用JQuery的Javascript 当点击一些按钮到angularjs函数时,如何提交文本框值?,javascript,json,angularjs,rest,Javascript,Json,Angularjs,Rest,我想做的是从两个文本框中提交两个单独的值。每个文本框都包含一个使用JQuery的datetimepicker。如何使用angularjs将我的2文本框值提交到javascript函数中 以下是我创建表单的方式: index.html <fieldset class="well the-fieldset"> <h4>Date</h4> <form class="form-inline" > <div clas
datetimepicker
。如何使用angularjs将我的2文本框值提交到javascript函数中
以下是我创建表单的方式:
index.html
<fieldset class="well the-fieldset">
<h4>Date</h4>
<form class="form-inline" >
<div class="form-group">
<label for="exampleInputName2">First Date</label>
<input type="text" class="form-control" id="First_Date" />
</div>
<div class="form-group">
<label for="exampleInputEmail2">Last Date</label>
<input type="text" class="form-control" id="Last_date" />
</div>
<button class="btn btn-success" ng-click="selectPOoutStanding(First_Date,Last_Date)" >Process</button>
</form>
</fieldset>
<table>
<thead>
<tr>
<th>No PO</th>
<th>Tanggal PO</th>
<th>Keterangan</th>
<th>Tanggal Jatuh Tempo</th>
<th>Divisi</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="listPOoutStanding in listPOoutStandings">
<td>{{listPOoutStanding.id}}</td>
<td>{{listPOoutStanding.tgl_opj}}</td>
<td>{{listPOoutStanding.ket}}</td>
<td>{{listPOoutStanding.tgl_jth_tempo}}</td>
<td>{{listPOoutStanding.divisi}}</td>
</tr>
</tbody>
</table>
</div>
</div>
传递值时,我在Java控制器中得到的是未定义的变量,下面是我的Java控制器:
SpringController.java
@RequestMapping(value = "/laporanoutstanding/{first_date}/{last_date}", method = RequestMethod.GET,headers="Accept=application/json")
public List<PoOutstandingList> selectLaporanPOoutstanding(@PathVariable String first_date, @PathVariable String last_date) {
List<PoOutstandingList> LaporanPoOutstanding = new ArrayList<PoOutstandingList>();
try {
LaporanPoOutstanding = laporanPOoutstanding.findAllPOoutstanding(first_date,last_date);
} catch (Exception e) {
throw new RuntimeException(e);
}
return LaporanPoOutstanding;
}
@RequestMapping(value=“/laporanoutstanding/{first_date}/{last_date}”,method=RequestMethod.GET,headers=“Accept=application/json”)
公共列表SelectLapoRanpoUnderstand(@PathVariable String first_date,@PathVariable String last_date){
List LAPORANPOPROUNTABLE=新建ArrayList();
试一试{
Laporanpounperstanding=Laporanpounperstanding.findAllPOoutstanding(第一天、最后一天);
}捕获(例外e){
抛出新的运行时异常(e);
}
返回未完成的任务;
}
我在@PathVariable
Stringfirst_date
和@PathVariable
Stringlast_date
中得到的内容在通过javascript传递时是未定义的,但当我通过webbrowser触发JSON服务时
它工作正常。这意味着在文本框中提交2个值时,我的javascript中缺少了一些东西。这里我遗漏了什么?您需要在输入控件中使用ng模型来获取angularjs中的值
<input type="text" class="form-control" ng-model="First_Date" id="First_Date" />
<input type="text" class="form-control" ng-model="Last_date" id="Last_date" />
然后在控制器内部,您可以使用
$scope.Last_date
或$scope.First_date
引用值,您需要在输入控件中使用ng模型以获取angularjs中的值
<input type="text" class="form-control" ng-model="First_Date" id="First_Date" />
<input type="text" class="form-control" ng-model="Last_date" id="Last_date" />
然后在控制器内部,您可以使用
$scope.Last_date
或$scope.First_date
引用值,您需要在输入控件中使用ng模型以获取angularjs中的值
<input type="text" class="form-control" ng-model="First_Date" id="First_Date" />
<input type="text" class="form-control" ng-model="Last_date" id="Last_date" />
然后在控制器内部,您可以使用
$scope.Last_date
或$scope.First_date
引用值,您需要在输入控件中使用ng模型以获取angularjs中的值
<input type="text" class="form-control" ng-model="First_Date" id="First_Date" />
<input type="text" class="form-control" ng-model="Last_date" id="Last_date" />
然后在控制器内部,您可以使用$scope.Last_date
或$scope.First_date
来引用尚未添加的值,这些值将控制器值绑定到视图
<div class="form-group">
<label for="exampleInputName2">First Date</label>
<input type="text" class="form-control" id="First_Date" ng-model="First_Date"/>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Last Date</label>
<input type="text" class="form-control" id="Last_date" ng-model="Last_Date" />
</div>
您尚未添加将控制器值绑定到视图的inputText
<div class="form-group">
<label for="exampleInputName2">First Date</label>
<input type="text" class="form-control" id="First_Date" ng-model="First_Date"/>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Last Date</label>
<input type="text" class="form-control" id="Last_date" ng-model="Last_Date" />
</div>
您尚未添加将控制器值绑定到视图的inputText
<div class="form-group">
<label for="exampleInputName2">First Date</label>
<input type="text" class="form-control" id="First_Date" ng-model="First_Date"/>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Last Date</label>
<input type="text" class="form-control" id="Last_date" ng-model="Last_Date" />
</div>
您尚未添加将控制器值绑定到视图的inputText
<div class="form-group">
<label for="exampleInputName2">First Date</label>
<input type="text" class="form-control" id="First_Date" ng-model="First_Date"/>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Last Date</label>
<input type="text" class="form-control" id="Last_date" ng-model="Last_Date" />
</div>
您必须像这样向输入中添加ng模型属性
<input type="text" ng-model="First_Date" class="form-control" id="First_Date" />
第二个呢
<input type="text" ng-model="Last_date" class="form-control" id="Last_date" />
您必须像这样在输入中添加ng模型属性
<input type="text" ng-model="First_Date" class="form-control" id="First_Date" />
第二个呢
<input type="text" ng-model="Last_date" class="form-control" id="Last_date" />
您必须像这样在输入中添加ng模型属性
<input type="text" ng-model="First_Date" class="form-control" id="First_Date" />
第二个呢
<input type="text" ng-model="Last_date" class="form-control" id="Last_date" />
您必须像这样在输入中添加ng模型属性
<input type="text" ng-model="First_Date" class="form-control" id="First_Date" />
第二个呢
<input type="text" ng-model="Last_date" class="form-control" id="Last_date" />