angularjs http 无刷新调用
来源:互联网 发布:sql server数据库备份 编辑:程序博客网 时间:2024/06/05 19:29
1.html页面
<body ng-app="myApp" ng-cloak>
<form id="form1" runat="server">
<div ng-controller="myController">
<ul>
<li ng-repeat="item in Users">{{item.name}}|{{item.gender}}
</li>
</ul>
</div>
</form>
</body>
2.javascript代码
var myApp = angular.module("myApp", []);
//myApp.value("BaseSource", {
// Users: [
// { "isBonusPoints": true, "name": "小芳", "likesubject": 2, "gender": 2, "integral": 100, "bonusPoints": 5 },
// { "isBonusPoints": true, "name": "小明", "likesubject": 1, "gender": 1, "integral": 111, "bonusPoints": 5 },
// { "isBonusPoints": false, "name": "小张", "likesubject": 2, "gender": 1, "integral": 98, "bonusPoints": 0 }
// ]
//});
myApp.service("Users", function () {
this.GetUser = function ($scope, $http) {
$http({
method: 'get', //get/post都可以
url: 'WebForm1.aspx?Type=1'
}).success(function (req) {
$scope.Users = req;
console.log(req);
})
}
});
myApp.controller("myController", ["$scope", "$http", "BaseSource", "Users", function ($scope, $http, BaseSource, Users) {
//$scope.Users = BaseSource.Users;
Users.GetUser($scope, $http);
}]);
3.后台获取数据
if (Request["Type"] == "1") {
string ResSource = "[{ \"isBonusPoints\": true, \"name\": \"小芳1\", \"likesubject\": 2, \"gender\": 2, \"integral\": 100, \"bonusPoints\": 5 },{ \"isBonusPoints\": true, \"name\": \"小明\", \"likesubject\": 1, \"gender\": 1, \"integral\": 111, \"bonusPoints\": 5 }, { \"isBonusPoints\": false, \"name\": \"小张\", \"likesubject\": 2, \"gender\": 1, \"integral\": 98, \"bonusPoints\": 0 } ]";
Response.Write(ResSource);
Response.End();
}
- angularjs http 无刷新调用
- angularjs ajax无刷新下载
- angularJS实现无刷新文件下载
- 无刷新ajax调用js
- ViewPager 调用 notifyDataSetChanged()无刷新
- 页面无刷新调用数据(IFRAME+js)
- XMlHTTP ajax实现数据无刷新调用
- 真正页面无刷新调用数据原理
- 调用notifyDataSetChanged刷新PullToRefreshListView列表无反应
- angularJS 循环调用$http 服务直到成功
- angularjs $http调用接口的方式
- angularjs $http调用接口的方式
- (转)XML HTTP实现无刷新页面功能
- 无刷新
- angularjs $http
- AngularJS $http
- angularjs $http
- AngularJS http
- 单链表逆转
- CS0619号错误是什么
- MFC: 获得关机消息;阻止Windows关机
- Runloop的最简单使用
- web界面设计的原则和总结
- angularjs http 无刷新调用
- Android基础之CountDownLatch
- BeautifulSoup不能完整识别网页html代码
- 操作符重载 – 下 --- 用 成员函数 来重载操作符
- react-native-code-push与cocoapods pod 'SSZipArchive'冲突
- 关键字typedef与#define的异同
- 修改Tomcat默认端口号
- Python爬虫实战之爬取链家广州房价_01简单的单页爬虫
- if和switch的区别