jmbledsoe / angularjs-visualstudio-intellisense

Visual Studio extension providing statement completion for injected AngularJS components in JavaScript files.
MIT License
110 stars 22 forks source link

Requires angular module to be saved to global scope #7

Closed Nel75 closed 9 years ago

Nel75 commented 9 years ago

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);
}
jmbledsoe commented 9 years ago

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.

jmbledsoe commented 9 years ago

Readme updated.

Nel75 commented 9 years ago

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.