错误:[$ injector:unpr]未知提供者:routeFilterProvider< - routeFilter(coffeescript)

时间:2015-12-11 18:34:40

标签: angularjs routing coffeescript minifiedjs

基本上我想在没有部署的情况下从CMS创建角度应用的路由。所以我想尝试做一些类似于本教程的内容:http://gonzalo123.com/2014/06/30/setting-up-states-from-a-json-file-in-angularjs-applications/。基本上我有一个json文档,其中包含可用路由列表,我希望能够按名称访问这些路由。这就是我所拥有的:
newco.js:

@newco = angular.module 'newco', [
  'ui.bootstrap',
  'ngResource',
  'ngRoute',
  'ngIdle',
  'LocalStorageModule',
  'checklist-model',
#  'zj.namedRoutes',
  'ng.deviceDetector',
  'noCAPTCHA',
  'feature-flags',
  'ui.router',
  'Routing'
]

@newco.config(['$provide', '$locationProvider','$httpProvider', '$stateProvider', '$urlRouterProvider', 'routerProvider', ($provide, $locationProvider, $httpProvider, $stateProvider, $urlRouterProvider, routerProvider) ->
  $httpProvider.interceptors.push('localeInterceptor');
  $locationProvider.html5Mode(false);
  $locationProvider.hashPrefix('!');
  $urlRouterProvider.otherwise '/'
  routerProvider.setCollectionUrl
  return

  $stateProvider.state '/',
    url: '/'
    templateUrl: '/pages/home/index-v3'
  $urlRouterProvider.otherwise '/home'
  routerProvider.setCollectionUrl
  return
]).controller 'NewHomeController', ($scope, router) ->
  $scope.reload = ->
    router.setUpRoutes()
    return
  return

routing.js.coffee:

angular.module('Routing', [ 'ui.router' ]).provider('router', ($stateProvider) ->
  urlCollection = undefined

  @$get = ($http, $state, CMSS3Url) ->
    { setUpRoutes: ->
      $http.get(CMSS3Url + '/routes.json').success (collection) ->
        _.each collection.routes, (route) ->
          $stateProvider.state route,
            url: route
            templateUrl: '/pages/home/new_index'
            controller: 'NewHomeController'
        return
      return
    }

  @setCollectionUrl = (url) ->
    urlCollection = url
    return

  return
).run (router) ->
  router.setUpRoutes()
  return

收藏:

{
  "routes": [
    "/route1",
    "/route2",
    "/"

  ]
}

因为我从简单的js转变为咖啡,我认为这可能是一个缩小问题,但老实说我不知道​​。任何帮助是极大的赞赏。

0 个答案:

没有答案