私はAngularJSを初めて使っています。私は毎日勉強しています。しかし、2日間は、この変更に問題が残っています。私は2つの選択入力を持っています。第2の入力は、第1の入力オプションに基づく値を有する。私はそのような例を行ったが、今はうまくいかない。私はコンビネモジュールを持っているのか、それとも選択されているのかはわかりません。ここに私のコードです:選択をトリガしないときのAngularJS ng-change
<div class="col-lg-4">
<section class="panel">
<div class="panel-body">
<div class="panel-heading">Adresa teren</div>
<form class="form-horizontal" data-validate="parsley"
action="forms.php?forms=update_land_address" method="post" id="form_land_address">
<div class="form-group">
<label class="col-sm-3 control-label">Judet</label>
<div class="col-sm-9">
<input type="hidden" id="land_address_judet_id"
value="<?php echo $land_address_data[0]['id_judet']; ?>">
<div ng-app="land_address_judet_module" ng-controller="land_address_judet_controller">
<select id="land_address_judet" class="form-control" name="land_address_judet" ng-change="ChangeJudet()" ng-model="uat_superior_module">
<option ng-repeat="h in rez" value="h.id_judet"
ng-value="h.id_judet" ng-selected="h.id_judet=='<?php echo $land_address_data[0]['id_judet']; ?>'" >
{{h.judet}}
</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">UAT</label>
<div class="col-sm-9" ng-controller="uat_superior" ng-app="uat_superior_module">
<select id="land_address_uat" class="form-control" name="land_address_uat">
<option ng-repeat="h in rez"
value="h.sirsup" <?php if ("h.sirsup" == $land_address_data[0]['sirsup']) {
echo "selected=\"selected\"";
} ?> ng-selected="h.sirsup==<?php echo $land_address_data[0]['sirsup']; ?>">
{{h.localitate_superioara}}
</option>
</select>
</div>
</form>
</div>
</section>
</div>
そしてこれは、角度のスクリプトからの部分である:上記のコード、最初の入力が空白で、私はデータを変更すると、それがないから
var tip_judet = 'get_judet';
var address_judet = "cautare.php?tip=get_judet";
var app_judet = angular.module("land_address_judet_module", []);
app_judet.controller('land_address_judet_controller', function ($scope, $http) {
$http.get(address_judet)
.then(function (response) {
$scope.rez = response.data.records;
});
});
var tip3 = 'get_uat_superior';
var judet = $('#land_address_judet_id').val();
var address3 = "cautare.php?tip=" + tip3 + "&id_judet=" + judet;
var app3 = angular.module("uat_superior_module", []);
app3.controller('uat_superior', function ($scope, $http) {
$http.get(address3)
.then(function (response) {
$scope.rez = response.data.records;
});
$scope.ChangeJudet = function() {
alert('da');
judet = $('#land_address_judet').val();
var address = "cautare.php?tip=" + tip3 + "&id_judet=" + judet;
$http.get(address)
.then(function (response) {
$scope.rez = response.data.records;
});
}
});
angular.module("CombineModule", ["formular_land", "formular_land_address", "uat_superior_module", "land_address_judet_module"]);
$ scope.ChangeJudet
が