@@ -533,9 +533,9 @@ function $HttpProvider() {
533
533
*
534
534
*
535
535
* @example
536
- <example>
536
+ <example module="httpExample" >
537
537
<file name="index.html">
538
- <div ng-controller="FetchCtrl ">
538
+ <div ng-controller="FetchController ">
539
539
<select ng-model="method">
540
540
<option>GET</option>
541
541
<option>JSONP</option>
@@ -557,30 +557,32 @@ function $HttpProvider() {
557
557
</div>
558
558
</file>
559
559
<file name="script.js">
560
- function FetchCtrl($scope, $http, $templateCache) {
561
- $scope.method = 'GET';
562
- $scope.url = 'http-hello.html';
563
-
564
- $scope.fetch = function() {
565
- $scope.code = null;
566
- $scope.response = null;
567
-
568
- $http({method: $scope.method, url: $scope.url, cache: $templateCache}).
569
- success(function(data, status) {
570
- $scope.status = status;
571
- $scope.data = data;
572
- }).
573
- error(function(data, status) {
574
- $scope.data = data || "Request failed";
575
- $scope.status = status;
576
- });
577
- };
560
+ angular.module('httpExample', [])
561
+ .controller('FetchController', ['$scope', '$http', '$templateCache',
562
+ function($scope, $http, $templateCache) {
563
+ $scope.method = 'GET';
564
+ $scope.url = 'http-hello.html';
565
+
566
+ $scope.fetch = function() {
567
+ $scope.code = null;
568
+ $scope.response = null;
569
+
570
+ $http({method: $scope.method, url: $scope.url, cache: $templateCache}).
571
+ success(function(data, status) {
572
+ $scope.status = status;
573
+ $scope.data = data;
574
+ }).
575
+ error(function(data, status) {
576
+ $scope.data = data || "Request failed";
577
+ $scope.status = status;
578
+ });
579
+ };
578
580
579
- $scope.updateModel = function(method, url) {
580
- $scope.method = method;
581
- $scope.url = url;
582
- };
583
- }
581
+ $scope.updateModel = function(method, url) {
582
+ $scope.method = method;
583
+ $scope.url = url;
584
+ };
585
+ }]);
584
586
</file>
585
587
<file name="http-hello.html">
586
588
Hello, $http!
0 commit comments