Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Why does this fail?
  2.  
  3. angular.module('myApp.controllers', []).controller('SiteController', function($scope) {
  4.     $scope.publisher = 'SitePoint';
  5.     $scope.type = 'Web Development';
  6.     $scope.name = 'Scope for SiteController';
  7. });
  8.  
  9. angular.module('myApp.controllers', []).controller('BookController', function($scope) {
  10.     $scope.books = ['Jump Start HTML5', 'Jump Start CSS', 'Jump Start Responsive Web Design'];
  11.     $scope.name = 'Scope for BookController';
  12. });
  13.  
  14.  
  15. ============================================================================
  16. AND YET THIS WORKS?
  17.  
  18. angular.module('myApp.controllers', []).controller('SiteController', function($scope) {
  19.     $scope.publisher = 'SitePoint';
  20.     $scope.type = 'Web Development';
  21.     $scope.name = 'Scope for SiteController';
  22. });
  23.  
  24. angular.module('myApp.controllers').controller('BookController', function($scope) {
  25.     $scope.books = ['Jump Start HTML5', 'Jump Start CSS', 'Jump Start Responsive Web Design'];
  26.     $scope.name = 'Scope for BookController';
  27. });
  28.  
  29.  
  30. ============================================
  31.  
  32. The difference being that there is no 2nd argument in the second module() call. I'm getting the error "Controller names should start with an uppercase character and end with the suffix Controller. For example: UserController.
  33. Multiple modules with name "myApp.controllers" are being created and they will overwrite each other." with the first one. Does the 2nd argument have something to do with differentiating the controller names also?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement