Javascript 如何在angular js中设置输入文本字段的代码?
我做了一个自动完成。首先我从服务器下载数据,然后用我的stationCode在文本字段中写入任何内容。我的json数组中有两个东西stationCode和stationName数组。现在我需要在输入文本字段中设置所选的站点代码。你能告诉我是什么吗当用户选择autosuggest的任何一行时,在输入文本字段上设置站点代码值的更好方法 这是我的密码Javascript 如何在angular js中设置输入文本字段的代码?,javascript,angularjs,angularjs-directive,angularjs-scope,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Directive,Angularjs Scope,Angularjs Ng Repeat,我做了一个自动完成。首先我从服务器下载数据,然后用我的stationCode在文本字段中写入任何内容。我的json数组中有两个东西stationCode和stationName数组。现在我需要在输入文本字段中设置所选的站点代码。你能告诉我是什么吗当用户选择autosuggest的任何一行时,在输入文本字段上设置站点代码值的更好方法 这是我的密码 <!DOCTYPE html> <html> <head> <link rel="stylesheet
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/foundation.css" />
</head>
<body ng-app="myapp">
<div ng-controller="cnt">
<input type="text" ng-model="searchText.stationCode">
<table ng-show="searchText.stationCode && searchText.stationCode.length != 0">
<tr id="$index"ng-repeat= "a in d.data | filter:searchText" ng-click="getselectedRow(searchText)">
<td> {{a.stationCode}} </td>
<td> {{a.stationName}} </td>
</tr>
</table>
</div>
</body>
<script src="js/angular.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
</html>
function cnt($scope,$http){
$http.get("http://184.106.159.143:8180/FGRailApps/jservices/rest/stationList")
.success(function (data) {
//alert(data);
$scope.d=data;
}).error(function(data){
alert("error")
});
$scope.getselectedRow=function(obj){
alert(obj.stationCode)
}
}
{{a.stationCode}}
{{a.stationName}}
函数cnt($scope,$http){
$http.get(“http://184.106.159.143:8180/FGRailApps/jservices/rest/stationList")
.成功(功能(数据){
//警报(数据);
$scope.d=数据;
}).错误(函数(数据){
警报(“错误”)
});
$scope.getselectedRow=函数(obj){
警报(目标站代码)
}
}
拨弄
请禁用浏览器的web安全性您能在JSFIDLE中提供您的代码吗?我已经给出了完整的代码。我将尝试在运行FIDDLE之前禁用web安全性。您是否尝试过$scope.d=JSON.parse(data)?为什么我们需要“禁用安全性”?就说明/指导而言,这有点令人担忧。