我有下面的選擇框我想通過選擇框的ID的功能角度JS
<select class="form-control" ng-model="community_type_id">
<option ng-repeat="x in myData" value="{{ x.community_type_id }}" ng-click="sendID(x.community_type_details)">{{ x.community_type_details }}</option>
</select>
我想x.community_type_id傳遞給函數sendID這樣。但不適合我的情況。
var app = angular.module('EntityApp', []);
app.controller('EntityAppCntroller', function($scope, $http) {
$http.get("http://122.322.5.459:8080/apartment/community/type/list").then(function(response) {
$scope.myData = response.data.type;
});
$scope.sendID = function(id) {
alert(id);
$http.get("http://11.22.33.44:8080/apartment/community/sub/type/list/" + id).then(function(response) {
$scope.myDatas = response.data.type;
});
}
});
你應該在'
'ng-model =「community_type_id」ng-change =「sendID('community_type_id')」'而不是在選擇元素上使用它。 – Jai