[英]AngularJS Controller reapply or update data after jQuery change
I have a issue on updating a input value based on another input value. 我在基于另一个输入值更新输入值时遇到问题。 I've "J" input and "U" input.
我有“ J”输入和“ U”输入。 When J is changed I need the values updated in U input.
当J改变时,我需要在U输入中更新值。 And I want to do this with angularjs.
我想用angularjs做到这一点。 I've done a simple angularj js controller to get the values from database:
我已经完成了一个简单的angularj js控制器来从数据库获取值:
<script>
var tip = "uat_superior";
var judet = $('#judet').val();
var address = "cautare.php?tip=" + tip + "&judet="+judet;
var app = angular.module('myApp', []);
app.controller('uat_superior_data', function ($scope, $http) {
$http.get(address)
.then(function (response) {
$scope.rez = response.data.records;
});
$scope.OnChangeJudet=function()
{
$http.get(address)
.then(function (response) {
$scope.rez = response.data.records;});
}
});
But it doesn't work. 但这是行不通的。 How can I make the controller to update the data after a input is changed?
更改输入后,如何使控制器更新数据? I've tried with
$('#inputJ').change(function () { the code above});
我已经尝试过
$('#inputJ').change(function () { the code above});
and it doesn't work. 而且不起作用。 And Google didn't helped me too much for this question.
对于这个问题,谷歌并没有给我太多帮助。 THank you
谢谢
<div ng-app="myApp" ng-controller="uat_superior_data" id="uat_superior_data">
<div class="form-group">
<select name="judet" id="judet" ng-change="OnChangeJudet()" ng-model="myValue3">
<?php
$clasa_judet = new oras();
$judete = $clasa_judet->get_judet();
for ($b = 0; $b < count($judete); $b++) {
echo '<option value="' . $judete[$b]['id_judet'] . '">' . $judete[$b]['judet'] . ' </option>';
}
?>
</select>
</div>
<div class="form-group">
<select>
<option ng-repeat="x in rez">{{x.localitate_superioara}}</option>
</select>
</body>
<script>
var tip = "uat_superior";
var judet = $('#judet').val();
var address = "cautare.php?tip=" + tip + "&judet="+judet;
var app = angular.module('myApp', []);
app.controller('uat_superior_data', function ($scope, $http) {
$http.get(address)
.then(function (response) {
$scope.rez = response.data.records;
});
$scope.OnChangeJudet=function()
{
judet = $('#judet').val();
address = "cautare.php?tip=" + tip + "&judet="+judet;
$http.get(address)
.then(function (response) {
$scope.rez = response.data.records;});
}
});
</script>
This is the working code ! 这是工作代码!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.