1

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 ?

3 Answers 3

2

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

Ui-Router Issue for requirejs load with AMD

Sign up to request clarification or add additional context in comments.

Comments

0
"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!

2 Comments

I already did that . But somehow its telling Cannot read property 'router' of undefined in require.js
It worked for me: ``` uiRouter: { deps: ["angular", "ngRoute"],```
0

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.

4 Comments

Could you please elaborate more your answer adding a little more description about the solution you provide?
first, link use define of requirejs to load the ui-router, this is ok, but, not
requirejs, angularjs have two module management system. first, in app.js, joy use define of requirejs to load the ui-router, this is ok, but, not use angular.module to attach ui-router to current module. then, ui.router not a good name.
in app.js, you should use angular.module( 'app',['ui.router'] ) to attach the ui-router module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.