AngularJS for $http
来源:互联网 发布:淘宝lgg5怎么这么便宜 编辑:程序博客网 时间:2024/06/03 09:24
index.html
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>AngularJS for login </title> <script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script> <script src=JS/city.js></script> <style>table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 3px;}table tr:nth-child(odd){ background-color: #f1f1f1;}table tr:nth-child(even) { background-color: #ffffff;}</style> </head><body> <div ng-app="myApp" ng-controller = "myAppCtrl"> <table> <tr ng-repeat="x in res"> <td>{{ x.province }}</td> <td>{{ x.city }}</td> </tr> </table> </div> </body></html>city.js
var app = angular.module('myApp', []);app.controller('myAppCtrl', function($scope, $http) {$scope.res = "测试"; $http.get("admin/getcitys").success(function(res) {$scope.res = res ;}) ;});
package com.liyang.controller;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import com.google.gson.Gson;@Controller@RequestMapping(value = "/admin")public class AdminController { @RequestMapping(value = "getcitys" , produces="text/html;charset=UTF-8")@ResponseBodypublic String getCitys(){ Map<String , String> city = new HashMap<String, String>() ; city.put("北京市" , "北京"); city.put("上海市" , "上海"); city.put("天津市" , "天津"); city.put("重庆市" , "重庆"); city.put("黑龙江省" , "哈尔滨"); city.put("吉林省" , "长春"); city.put("辽宁省" , "沈阳"); city.put("内蒙古自治区" , "呼和浩特"); city.put("河北省" , "石家庄"); city.put("新疆维吾尔自治区" , "乌鲁木齐"); city.put("甘肃省" , "兰州"); city.put("青海省" , "西宁"); city.put("陕西省" , "西安"); city.put("宁夏回族自治区" , "银川"); city.put("河南省" , "郑州"); city.put("山东省" , "济南"); city.put("山西省" , "太原"); city.put("安徽省" , "合肥"); city.put("湖南省" , "长沙"); city.put("湖北省" , "武汉"); city.put("江苏省" , "南京"); city.put("四川省" , "成都"); city.put("贵州省" , "贵阳") ; city.put("云南省" , "昆明") ; city.put("广西壮族自治区" , "南宁") ; city.put("西藏自治区" , "拉萨") ; city.put("浙江省" , "杭州") ; city.put("江西省" , "南昌") ; city.put("广东省" , "广州") ; city.put("福建省" , "福州") ; city.put("台湾省" , "台北") ; city.put("海南省" , "海口") ; city.put("香港特别行政区" , "香港") ; city.put("澳门特别行政区" , "澳门") ; List<Map<String , String> > res = new ArrayList<Map<String , String>>() ; for(Map.Entry<String , String> e : city.entrySet()){ Map<String , String> c = new HashMap<String , String>() ; c.put("province" , e.getKey()) ; c.put("city", e.getValue()) ; res.add(c) ; } Gson gson = new Gson() ; return gson.toJson(res) ;}}
0 0
- AngularJS for $http
- angularjs $http
- AngularJS $http
- angularjs $http
- AngularJS http
- AngularJS $http
- 快速解决AngularJS 中的 Cross origin requests are only supported for HTTP
- XMLHttpRequest cannot load file. Cross origin requests are only supported for HTTP angularjs
- AngularJs(四):$Http,$resource
- AngularJS $http Service
- AngularJS $http使用
- AngularJS中$http
- 10009---AngularJS Http
- AngularJS(03)---Http对象
- AngularJS $http service
- AngularJS $http简介1
- AngularJS - $http的config
- AngularJS中http拦截
- poj1502——MPI Maelstrom(dijkstra算法)
- 刪數 纪中3097 dp
- Android中内存泄露与如何有效避免OOM总结(转)
- 整洁代码--写好方法(函数)
- NSFileManager的介绍
- AngularJS for $http
- 算术表达式计算(栈的应用)
- Qt的正则匹配
- android中使用WebView加载html字符串
- 四种框架分别实现百万 websocket 常连接的服务器
- 九个数据结构面试题(附程序)
- android SDK更新资源---无需翻墙
- React-Router与Tomcat
- 【HDU 杭电 4521 小明系列问题——小明序列】