Using angularJS with requireJS - cannot read property 'module' of undefined

后端 未结 2 1213
臣服心动
臣服心动 2021-02-10 22:46

I had started writing an app using angularJS. After a few weeks, I suddenly realized that I should have used require JS from the beginning to load my modules. Yes, I know, it wa

2条回答
  •  隐瞒了意图╮
    2021-02-10 23:36

    Looking at the sources for Angular, I do not see anywhere that it calls RequireJS' define so you need a shim for it. Add this to your shim configuration:

    angular: {
        exports: "angular"
    }
    

    By the way, the priority field in your configuration is obsolete. Either you use RequireJS 2.x which ignores this field because priority is supported only by RequireJS 1.x. Or you use RequireJS 1.x which would honor priority but would ignore the shim field because shim was introduced in 2.x. My suggestion: use RequireJS 2.x and remove priority.

提交回复
热议问题