我是Angular JS的新手。我有以下<select>
个选项,我必须发送社区的ID,即x.community_type_id
来获取子社区。 p>
<select>
<option ng-repeat="x in myData" ng-click="sendID({{ x.community_type_id }})">{{ x.community_Type }}</option>
</select>
现在我正在使用以下代码从Web服务获取数据以选择选项。
var app = angular.module('EntityApp', []);
app.controller('EntityAppCntroller', function($scope, $http) {
$http.get("http://111.222.22.333:1081/apartment/community/type/list")
.then(function (response) {
$scope.myData = response.data.type;
});
$scope.sendID = function (id) {
alert(langKey);
}
});
我想将x.community_type_id发送到网络服务。 那个webservice网址是这样的:
http://11.338.41.149:8481/apartment/register/sub/community/type
答案 0 :(得分:2)
在Angular中,当属性以ng-
开头时,它被评估为JavaScript,因此您可以取消双花括号:
<select>
<option ng-repeat="x in myData" ng-click="sendID(x.community_type_id)">{{ x.community_Type }}</option>
</select>
答案 1 :(得分:0)
删除ng-click
函数
<select>
<option ng-repeat="x in myData" ng-click="sendID( x.community_type_id )">{{ x.community_Type }}</option>
</select>
答案 2 :(得分:0)
试试这个 HTML
ng-click="sendID( x.community_type_id )"
JS
$scope.sendID = function (id) {
$http({
method:'GET',
url:'yoururl'+id,
data:{'id':id}
///
})
}
答案 3 :(得分:0)
试试这个
<select ng-model="model" ng-options="x.community_type_id as
x.community_Type for x in myData" ng-click="sendID(model)">
<option ></option>
</select>