繁体   English   中英

Angular-Browserify + ui.router-状态产生“未捕获的对象”

[英]Angular-Browserify + ui.router - States produces “Uncaught object”

我有一个项目需要比大多数专门用于小型项目的角锥化种子播种机更好的结构。 是否有可能需要所有路线的索引? 这样的(在RequireJS上)

我的项目正在使用gulp.js和coffeescript

我的项目结构

- assets/
    - bower_components/
    - coffee/
        - directives/
            - login.coffee
            - registration.coffee
        - services/
            - auth.coffee
            - user.coffee
        - utils/
            - states/
                    - auth.coffee
                    - dashboard.coffee
                    - index.coffee
                    - main.coffee
                    - modules.coffee
                    - otherwise.coffee
        - app.coffee
        - main.coffee

资产/主要咖啡

bootstrap = require '../bower_components/bootstrap-sass-official/vendor/assets/javascripts/bootstrap'
$ = require '../bower_components/jquery/dist/jquery'

$(document).ready ->
    angular = require '../bower_components/angular/angular'
    angular_ui_router = require '../bower_components/angular-ui-router/release/angular-ui-router'
    lumina = require './app'
    services = require './services/modules'
    directives = require './directives/modules'
    states = require './utils/states/modules'

    return

资产/应用咖啡

app = angular.module 'app', ['ui.router']

module.exports = app

资产/实用程序/状态/模块。咖啡

otherwise = require './otherwise'
dashboard = require './dashboard'
auth = require './auth'
main = require './main'
index = require './index'

资产/实用程序/状态/auth.coffee

app = require '../../app'

app.config [($stateProvider) ->
    auth = 
        name: 'main.auth'
        abstract: true
        resolve:
            auth: AuthSrvc ->
                return AuthSrvc.check()

    $stateProvider.state(auth);
]

/assets/utils/states/dashboard.coffee

app = require '../../app'

app.config [($stateProvider) ->

]

/assets/utils/states/index.coffee

app = require '../../app'

app.config [($stateProvider) ->
    index =
        name: 'main.index'
        url: '/'
        resolve:
            auth: AuthSrvc ->
                return AuthSrvc.check()

    $stateProvider.state(index)
]

/assets/utils/states/main.coffee

app = require '../../app'

app.config [($stateProvider) ->
    main =
        name: 'main'
        abstract: true
        templateUrl: '../views/main/template.html'

    $stateProvider.state(main);
]

/assets/utils/states/otherwise.coffee

app = require '../../app'


app.config [($urlRouterProvider) ->
    $urlRouterProvider.otherwise '/'
]

当我尝试加载状态文件时,出现“未捕获对象”错误。 而且我不知道为什么。

这是由于没有注入依赖项。 这就是我形成配置/状态/其他内容的方式。

app.config [($stateProvider) ->
    auth = 
        name: 'main.auth'
        abstract: true
        resolve:
            auth: AuthSrvc ->
                return AuthSrvc.check()

    $stateProvider.state(auth);
]

注意第1行,其中我为最小化注释了依赖项。 我没有同样地注释依赖项: app.config [ '$stateProvider' , ($stateProvider) ->

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM