jmbledsoe/angularjs-visualstudio-intellisense

Requires angular module to be saved to global scope

Closed this issue · 3 comments

Thank you so much for this awesome module!! Couldn't find anything else out there like it. Makes coding Angular in VS a lot easier and much more fun. I just had some trouble getting it to work since I was saving my angular module to an object to emulate namespacing rather than to the global scope which this module requires as shown in snippet below. So thought maybe just a mention of that requirement in the readme might help someone else.

// Search the window object for globally-defined angular modules, and track them if they are found.
if (window) {
forEach(window, function (obj) {
if (isAngularModule(obj)) {
trackModule(obj);
}
});
}

function isAngularModule(obj) {
    // Angular modules all have names and invoke queues and core provider functions.
    return angular.isString(obj.name) &&
        angular.isArray(obj._invokeQueue) &&
        angular.isFunction(obj.provider) &&
        angular.isFunction(obj.constant) &&
        angular.isFunction(obj.value) &&
        angular.isFunction(obj.factory) &&
        angular.isFunction(obj.service);
}

You are correct. Modules must either be declared in the file that you want Intellisense in, or else declared as properties of the window object. I thought about recursively searching the window object hierarchy for modules but this seemed far too intensive.

Readme updated.

Yeah, I agree. Thanks!

On Oct 13, 2014, at 11:57 AM, John Bledsoe notifications@github.com wrote:

You are correct. Modules must either be declared in the file that you want Intellisense in, or else declared as properties of the window object. I thought about recursively searching the window object hierarchy for modules but this seemed far too intensive.


Reply to this email directly or view it on GitHub.