将modelObject与angularjs范围变量绑定的最佳方法是什么。 我试过如下
//controller
public ModelAndView getUsers(){
ModelAndView mav = new ModelAndView();
mav.addObejct("username","somename");
mav.setViewName("users");
return mav;
}
//jsp
<input ng-init="name='${username}'">
{{name}}
//output
somename
用于任何其他对象
//controller
public ModelAndView getUsers(){
ModelAndView mav = new ModelAndView();
List<String> username = new ArrayList();
username.add("steve");
username.add("mark");
username.add("james");
mav.addObejct("usernames",username);
mav.setViewName("users");
return mav;
}
//jsp
<input ng-init="name='${username}'">
{{name}}
//output
[steve,james,mark]// the way looking like array but it is string format
谢谢你。