我在這裏有2個下拉菜單。我的問題是,我只想獲取省下拉列表中的元素值,並以ng爲單位傳遞變量 - 如果在城市下拉列表中。例如,所選省份的值是3,那麼ng-if是值=== province.city.province_id。請幫忙。謝謝。獲取元素值中的值並在ng中使用它 - if
$http.get(API_URL + "/register").then(function(response) {
$scope.countries = response.data['countries'];
$scope.provinces = response.data['provinces'];
//alert(response.data['provinces'].toSource());
/*$('select[id=selProvince]').change(function() {
\t \t \t \t \t var tempProv = $(this).val();
\t \t \t \t \t \t
\t \t \t \t });*/
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="form-group form-group-default">
<label class="">Province</label>
<select id="selProvince" class="full-width" data-placeholder="Select Province" data-init-plugin="select2" tabindex="-1" title="">
<option ng-repeat="province in provinces" value="{{province.id}}">{{province.name}}</option>
</select>
</div>
<div class="form-group form-group-default">
<label class="">City</label>
<select id="selCity" class="full-width" data-placeholder="Select City" data-init-plugin="select2" tabindex="-1" title="">
<option ng-repeat="province in provinces" ng-if="value === province.city.province_id" value="{{province.city.id}}">{{province.city.name}}</option>
</select>
</div>
你的js代碼在哪裏? – Sreekanth
你試過'$ scope.value'嗎? – Prometheus
我在我的js裏面有這個函數,但是我不能把函數裏面的函數傳給我的js,在我的html – kwell