Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c6016a6

Browse files
victorbpetebacondarwin
authored andcommittedNov 14, 2013
docs(tutorial): change controllers to not have name twice
While giving the controller function a name helps with debugging, since otherwise your controller will be anonymous in stack traces, passing the name to both the `controller()` method and as the function name is confusing for beginners. Closes #4415
1 parent 977e2f5 commit c6016a6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed
 

‎docs/content/tutorial/step_02.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ __`app/js/controllers.js`:__
8181

8282
var phonecatApp = angular.module('phonecatApp', []);
8383

84-
phonecatApp.controller('PhoneListCtrl', function PhoneListCtrl($scope) {
84+
phonecatApp.controller('PhoneListCtrl', function ($scope) {
8585
$scope.phones = [
8686
{'name': 'Nexus S',
8787
'snippet': 'Fast just got faster with Nexus S.'},

‎docs/content/tutorial/step_04.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ __`app/js/controllers.js`:__
6767
<pre>
6868
var phonecatApp = angular.module('phonecatApp', []);
6969

70-
phonecatApp.controller('PhoneListCtrl', function PhoneListCtrl($scope) {
70+
phonecatApp.controller('PhoneListCtrl', function ($scope) {
7171
$scope.phones = [
7272
{'name': 'Nexus S',
7373
'snippet': 'Fast just got faster with Nexus S.',

‎docs/content/tutorial/step_05.ngdoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ __`app/js/controllers.js:`__
5656
<pre>
5757
var phonecatApp = angular.module('phonecatApp', []);
5858

59-
phonecatApp.controller('PhoneListCtrl', function PhoneListCtrl($scope, $http) {
59+
phonecatApp.controller('PhoneListCtrl', function ($scope, $http) {
6060
$http.get('phones/phones.json').success(function(data) {
6161
$scope.phones = data;
6262
});
@@ -79,7 +79,7 @@ json response and parsed it for us!
7979
To use a service in angular, you simply declare the names of the dependencies you need as arguments
8080
to the controller's constructor function, as follows:
8181

82-
function PhoneListCtrl($scope, $http) {...}
82+
phonecatApp.controller('PhoneListCtrl', function ($scope, $http) {...}
8383

8484
Angular's dependency injector provides services to your controller when the controller is being
8585
constructed. The dependency injector also takes care of creating any transitive dependencies the
@@ -145,7 +145,7 @@ __`app/js/controllers.js:`__
145145
var phonecatApp = angular.module('phonecatApp', []);
146146

147147
phonecatApp.controller('PhoneListCtrl', ['$scope', '$http',
148-
function PhoneListCtrl($scope, $http) {
148+
function ($scope, $http) {
149149
$http.get('phones/phones.json').success(function(data) {
150150
$scope.phones = data;
151151
});

‎docs/content/tutorial/step_07.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ __`app/js/controllers.js`:__
149149
var phonecatControllers = angular.module('phonecatControllers', []);
150150

151151
phonecatControllers.controller('PhoneListCtrl', ['$scope', '$http',
152-
function PhoneListCtrl($scope, $http) {
152+
function ($scope, $http) {
153153
$http.get('phones/phones.json').success(function(data) {
154154
$scope.phones = data;
155155
});

0 commit comments

Comments
 (0)