Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2831058

Browse files
committed
docs($http): update example to use a module
1 parent 7ccab81 commit 2831058

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

src/ng/http.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -533,9 +533,9 @@ function $HttpProvider() {
533533
*
534534
*
535535
* @example
536-
<example>
536+
<example module="httpExample">
537537
<file name="index.html">
538-
<div ng-controller="FetchCtrl">
538+
<div ng-controller="FetchController">
539539
<select ng-model="method">
540540
<option>GET</option>
541541
<option>JSONP</option>
@@ -557,30 +557,32 @@ function $HttpProvider() {
557557
</div>
558558
</file>
559559
<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+
};
578580
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+
}]);
584586
</file>
585587
<file name="http-hello.html">
586588
Hello, $http!

0 commit comments

Comments
 (0)