Issue
I've been using angular-seed as a starter project, and although it has changed its app structure within the past month or so I've decided to take a look at angular-sprout.
Angular-sprout doesn't have an updated index-async page, so I decided to fork the code and work on it. I've got everything wired up correctly, but now when I try to add a controller (via the module.controller()
function, I receive an error saying that module.controller
is undefined.
When I log angular.module('myModule')
to the console on my index-async.html
page, I get an angular object with the correct methods - filter()
, service()
, provider()
, etc - but controller
isn't there:
module Object {
_invokeQueue: Array[0],
_runBlocks: Array[0],
requires: Array[0],
name: "application.controllers",
provider: function…}
_invokeQueue: Array[0]
_runBlocks: Array[0]
config: function (){c[d||"push"]([a,b,arguments]);return g}
constant: function (){c[d||"push"]([a,b,arguments]);return g}
directive: function (){c[d||"push"]([a,b,arguments]);return g}
factory: function (){c[d||"push"]([a,b,arguments]);return g}
filter: function (){c[d||"push"]([a,b,arguments]);return g}
name: "application.controllers"provider: function (){c[d||"push"]([a,b,arguments]);return g}
requires: Array[0]run: function (a){d.push(a);return this}
service: function (){c[d||"push"]([a,b,arguments]);return g}
value: function (){c[d||"push"]([a,b,arguments]);return g}
__proto__: Object
}
(Sorry about the terrible formatting. I'll try to get a better console copy.)
When I log controller
from index-async:
controller undefined details-controller.js:13
This happens when I run the index-async page. However, on the regular index page, controller
is defined correctly and gives me an angular method:
controller function () {
invokeQueue[insertMethod || 'push']([provider, method, arguments]);
return moduleInstance;
} details-controller.js:13
Has anyone run into this before? For what it's worth, it seems as though controller
is the only module method that I'm missing, and I have absolutely no idea why this might be.
Solution
As it turns out....I decided to check the version of the Angular-loader I was using. Apparently, angular loader v1.0.0rc1 seems to cause this error, even if I'm using that version of AngularJS. I updated the loader to a later version which seems to fix the issue for some reason.
To note, there was no problem with the code itself. As it turns out, according to the documentation the loader overrides angular.module()
, which seems to be the root of the problem I experienced.
To do this, I had to clone angular-seed and run npm run update-index-async
to get the latest version of the loader code. Copying that into the sprout project seemed to fix the problem for Angular 1.0. (Now, to get this working with the latest version of Angular.) If you're using the script tag for the loader (not injecting it directly into your html page), you can likely just grab the latest version and link to that from your document.
Answered By - jedd.ahyoung
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.