Joy
Joy

Reputation: 7028

router not found error in ui-router angularjs with requirejs

I have included ui-router.js for angularjs . But somehow i am not getting it to work with requirejs.

require.config
baseUrl:"/Scripts/app"
paths :
    jquery      :   "libs/jquery/jquery-2.0.3"
    bootstrap   :   "libs/bootstrap/bootstrap"
    angular     :   "libs/angular/angular"
    domReady    :   "libs/requirejs/domReady"
    blockui     :   "libs/jquery.blockUI"
    "ui-router" :   "libs/angular/angular-ui-router"
    "angular-resource"  :   "libs/angular/angular-resource"

shim:
    jquery:
        exports:
            "jquery"

    bootstrap:
        depts:["jquery"]

    angular:
        exports:
            "angular"

    "ui-router":
        exports:
            "ui.router"
        deps : ['angular']

    blockui : 
        deps : ["jquery"]

        "angular-resource":
            deps: ['angular']

    deps :['app','utils/common']

require ['angular','jquery','bootstrap','routes'] ,(angular,$) ->   
    $(document).ready ->
        angular.bootstrap document,['app']

now my app.coffee is

define ['angular','angular-resource','ui-router'] , (angular) ->
angular.module 'app',['ngResource']

the console gives error in chrome

Uncaught TypeError: Cannot read property 'router' of undefined 

and

  TypeError: g is undefined    
g = g[part];

in firefox . Why am I not able to use ui-router as my module to load it into my modules for route.coffee ?

Upvotes: 1

Views: 5526

Answers (3)

guanjun
guanjun

Reputation: 26

if the module name is incorrect, requirejs can't load the script file. so your can't get the router. in development environment, you should open the console window, in this window, you should find the error from requirejs.

Upvotes: 0

Joy
Joy

Reputation: 7028

finally got the answer from this guy in ui-router project here is the answer link

Ui-Router Issue for requirejs load with AMD

Upvotes: 2

Tempschl
Tempschl

Reputation: 19

"ui-router":
    exports:
        "ui.router"
    deps : ['angular']

especially "ui.router" is the bad guy here.

solution: don't use the dot in its name. i used "uiRouter" even for the export!

Upvotes: 0

Related Questions