AngularJs练习Demo18 Resource

 1 @{
 2     Layout = null;
 3 }
 4 
 5 <!DOCTYPE html>
 6 
 7 <html>
 8 <head>
 9     <meta name="viewport" content="width=device-width" />
10     <title>Resource</title>
11     <script src="~/Scripts/angular.min.js"></script>
12     <script src="~/Scripts/angular-resource.min.js"></script>
13     <script type="text/javascript">
14         var m1 = angular.module("myApp", ["ngResource"]);
15         m1.controller("firstController", ["$scope", "$resource", function ($scope, $resource) {
16             var data = $resource("getData");
17             //支持的方法
18             /*
19             {
20              "get":{method:"get"},
21              "save":{method:"post"},
22              "query":{method:"get",isArray:true},
23              "remove":{method:"delete"},
24              "delete":{method:"delete"}
25             }
26             */
27 
28             $scope.data = data.get({"name": "zhangsan" }, function (data) {//Get请求并传参
29 
30             });//使用GET请求去请求数据
31           //  console.log(obj);
32             //  var objRe = $resource("", {});
33 
34 
35         }]);
36     </script>
37 </head>
38 <body>
39     <div ng-app="myApp">
40         <div ng-controller="firstController">
41             {{data.name}}
42             {{data.age}}
43 
44         </div>
45     </div>
46 </body>
47 </html>

 

posted @ 2016-06-21 23:13  编程猴子  阅读(213)  评论(0编辑  收藏  举报