AngularJs练习Demo18 Resource

Posted 编程猴子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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>

 

以上是关于AngularJs练习Demo18 Resource的主要内容,如果未能解决你的问题,请参考以下文章

AngularJs练习Demo9

AngularJs练习Demo6

AngularJs练习Demo5

AngularJs练习Demo8

AngularJs练习Demo1

AngularJs练习Demo4