Get started with angular-resource CDN

MIT licensed

Resource for RESTful web services in AngularJS.

Tags:
  • angular
  • framework
  • browser
  • rest
  • client-side

Stable version

Copied!

How to start using angular-resource CDN


<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/angular.min.js"></script>
  <script src="https://cdn.cdnhub.io/angular-resource/1.8.3/angular-resource.min.js"></script>
  <script src="app.js"></script>
  <style>
    body { margin: 0; }
  </style>
</head>
<body ng-app="myApp">
  <div ng-controller="MyController">
    <button ng-click="fetchData()">Fetch Data</button>
    <ul>
      <li ng-repeat="item in items">{{ item.name }}</li>
    </ul>
  </div>
</body>
</html>

// app.js
(function() {
  'use strict';

  angular
    .module('myApp', ['ngResource'])
    .controller('MyController', ['$scope', '$resource', function($scope, $resource) {
      $scope.items = [];

      $scope.fetchData = function() {
        $resource('/api/items').query(function(data) {
          $scope.items = data;
        });
      };
    }]);
})();
Copied!
Copied!
Copied!

All versions