在angular js选项中填充数组对象的简单要求,数组对象是从spring控制器填充的。
角度js有http获取请求,似乎问题是用http获取请求,原因,我添加了测试项目选项,当我包含http获取项目选项时没有填充。
下面是我简单要求的代码。
view.jsp的
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName= "Gopala";
$scope.lastName= "Krishnan";
$scope.items = [{name: 'one', age: 30 },{ name: 'two', age: 27 },{ name: 'three', age: 50 }];
$http.get('http://169.52.203.189:8080/LDODashBoard/AppView?appid=CV-APAC-CHECKOUT').success(function(data) {
$scope.appview = data;
});
});
</script>
<link rel="stylesheet" type="text/css" href="/LDODashBoard/css/mystyle.css" />
<meta charset="utf-8">
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p>selected item is : {{firstName}}</p>
<p>selected item is : {{lastName}}</p>
<select ng-model="selectedItem" ng-options="item.name for item in items">
</select>
<select ng-model="selectedItem1" ng-options="appview1.oDATE for appview1 in appview">
</select>
</div>
Controller.java
@RequestMapping(value = "/AppViewJson",method=RequestMethod.GET,produces={"application/xml", "application/json"})
public ModelAndView monitorUnixProcessJson(
@RequestParam(value = "appid", required = false) String appviewid,
Model model, HttpServletResponse response) {
log.info("inisde AppViewJson json method");
List <AppViewBatchDetails> appviewbatchlist = null;
try {
if (!appviewid.isEmpty()) {
WebPageURLReader webpagereader = new WebPageURLReader();
webpagereader.extractNeededAppview(appviewid);
webpagereader.executeRetrieveAppviewDetailsWrapper();
appviewbatchlist = webpagereader.returnMatchedAppviewJobs();
}
//return the dummy outputdisplay page, show nothing
return (new ModelAndView("AppviewDisplayJsonPage","appviewbatch",appviewbatchlist));
}
catch (Exception e){
log.error("exception received here!!!!");
}
return (new ModelAndView(CommonConstants.OutputDisplayPage,"",""));
}
}