title: Creating Service in Angular while using Require.js
body: <p>I am preparing a boiler Angular Application that will use AMD (require.js). So far I got it working, but I have issues with services. How do I incorporate service?</p>
  
  <p>This is Main.js:</p>
  
  <pre><code>require.config({  
  
  paths: {
  // These are the core components - without which our application could not run
  angular: '../lib/angular/angular',
  angularResource: '../lib/angular/angular-resource',
  
  // These are components that extend our core components
  jquery: '../lib/jquery/jquery-1.8.2.min',
  bootstrap: '../lib/bootstrap/js/bootstrap',
  underscore: '../lib/underscore/underscore',
  
  text: '../lib/require/text'  
  
  },
    shim: {
      'angular' : {'exports' : 'angular'},
      'angular-resource' : {deps:['angular']},
      'bootstrap': {deps:['jquery']},
      'underscore': {exports: '_'}
    },
    priority: [
      "angular"
    ],
    urlArgs: 'v=1.1'
  });
  
  require( [
    'angular',
    'app',
    'services/services',
    'services/dateGetter',
    'controllers/controllers',
    'controllers/navbar',
    'controllers/exampleTemplateController',
    'filters/filters',
    'directives/directives',
    'routes'
  ], function(angular, app) {
  
    angular.element(document).ready(function () {
      angular.bootstrap(document, ['myApp']);
    });
  });
  </code></pre>
  
  <p>This is how I developed controller:</p>
  
  <pre><code>define([
      'app',
      '../helpers/exampleFile'  //example of importing custom file.js in our controller.
  ],
  
  function(app, exampleFile) {
  
      'use strict';
      return app.controller('exampleTemplateController', [
          '$scope', 'dateGetter',
          function ($scope ) {
              $scope.sayHello = function(module) {
  
                alert("Current Date: " + dateGetter.getCustomDate + " " + exampleFile(module.name));
  
              }
          }
      ]);
  });
  </code></pre>
  
  <p>This is how I tried to develop service (failing miserably here):   </p>
  
  <pre><code> define([
      'app'
  ],
  
  function(app) {
          'use strict';
                  debugger;
          return app.factory('dateGetter', [
              '$scope',
              function ($scope ) {
                  $scope.getCustomName = function() {
                      return "THIS IS MY NAME";
                  }
              }
          ]);
      });
  </code></pre>
  
  <p>I think I am close, but something eludes me.</p>
  
  <p>Another question is, if I end up with lots of controllers and services, and we will... do I need to list each and everyone in main.js file (under require:)?</p>