Hi Experts
I am using 
.config(function($
I am passing the 
    templateUrl: 'chapter.html',
    controller: 'ChapterController'
but i do not know how to pass factory on which ChapterController is dependent.
I know through resolve attribute, i can pass the factory to ChapterController.
but what is the correct syntax.
Any help will be appreciated.
See the sample below. 
(function(angular) {
  'use strict';
angular.module('
.factory('
 var factory: {};
 factory.getText(){
 return 'Hello world'
 }
 return factory;
})
 .controller('BookController', function($scope, $routeParams) {
     $scope.name = "BookController";
     $scope.params = $routeParams;
 })
 .controller('
     $scope.name = "ChapterController";
     $scope.params = $routeParams;
     $scope.greetings = grettingTokenFactory.
 })
.config(function($
  $routeProvider
   .when('/Book/:bookId', {
    templateUrl: 'book.html',
    controller: 'BookController',
    resolve: {
      // I will cause a 1 second delay
      delay: function($q, $timeout) {
        var delay = $q.defer();
        $timeout(delay.resolve, 1000);
        return delay.promise;
      }
    }
  })
  .when('/Book/:bookId/ch/:
    templateUrl: 'chapter.html',
    controller: 'ChapterController'
  });
  // configure html5 to get links working on jsfiddle
  $locationProvider.html5Mode(
});
})(window.angular);
 
댓글 없음:
댓글 쓰기