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

Its not working #14

Closed serge-jerkezian closed 9 years ago

serge-jerkezian commented 9 years ago

First of all thank you for the effort in creating this project.

I have two files model.js and controller.js The controller can't fetch the methods inside my model.

controller.js

angular.module('app.controllers')
    .controller('CompanyProfileCtrl', [
        'CommonModel',
    function (CommonModel)
    {
        CommonModel. //no intellisense
    }]);

model.js

angular.module('app.services')
.factory('CommonModel', function ($http)
{
    function Model()
    {
        this.Search = function (json)
        {
            return $http({
                method: 'POST',
                url: companyUrl + 'Search',
                data: json
            });
        }...
      }
     return new Model; // return factory
});

i added angular.intellisense.js to the same directory as angular.js, as instructed. In the _references.js I pointed to angular.js and angular-ui-router.js (UI Router), maybe the UI Router is the problem ?

jmbledsoe commented 9 years ago

There's not really enough information here for an analysis of your issue. I can't see that your model.js class returns an appropriate factory. Create a Plunkr or pull request with a test case, marking the line where Intellisense fails and I will happily investigate your issue further.

serge-jerkezian commented 9 years ago

I added the factory return. If you think its not clear, i will create a Plunkr and link you.

jmbledsoe commented 9 years ago

I don't see a linkage between your app.services module and your app.controllers module. Are they dependent on one another somehow? I will need to see that relationship (in a JavaScript file) for the test, so a Plunkr would be helpful.

serge-jerkezian commented 9 years ago

ok I will create a Plunkr and link you, am currently at work... Thank you! I might not have the time to create a Plunkr today maybe on Monday. Have a nice weekend.

serge-jerkezian commented 9 years ago

Hello jmbledsoe, I created a Plunkr. However it can't seem to inject my controller so its not working. But locally it is working http://plnkr.co/edit/F4r3HpKDEbUkCyI5kKoL?p=preview

jmbledsoe commented 9 years ago

The reason your Plunkr wasn't working was because it didn't actually create the app.controllers and app.services modules, by specifying the "requires" parameter.

https://docs.angularjs.org/api/ng/function/angular.module

I believe that you're not getting Intellisense because the code does not establish a relationship between the app.services and app.controllers modules. When attempting to retrieve Intellisense within the controller, it doesn't have a relationship with app.services so doesn't resolve the dependency. Once this bug is fixed, you should get Intellisense. See my updates to the Plunkr:

http://plnkr.co/edit/BYC3mGNvVxRWXmkbi2bY

I'll leave the issue open awaiting your response.

serge-jerkezian commented 9 years ago

I added the injection of the service inside the controller as you suggest, however its still not working.

jmbledsoe commented 9 years ago

And you added creation of the modules, because that was missing as well?

What is the content of your _references.js file? This file needs to be up-to-date in order for Visual Studio to be able to find all of your JavaScript files.

serge-jerkezian commented 9 years ago

yup I added the inital [] to create the modules.

I have angularjs on the same directory as _reference.js

the _references.js

/// <autosync enabled="false" />
/// <reference path="angular-1.3.js" />
/// <reference path="angular-ui-router.js" />
jmbledsoe commented 9 years ago

You'll need your code files in there as well. Without references to model.js, controller.js and app.js then Visual Studio won't be able to find them, and so you won't get any Intellisense.

On Mon, Nov 24, 2014 at 9:27 AM, rtp-serge notifications@github.com wrote:

yup I added the inital [] to create the modules.

I have angularjs on the same directory as _reference.js

the _references.js

/// /// ///

— Reply to this email directly or view it on GitHub https://github.com/jmbledsoe/angularjs-visualstudio-intellisense/issues/14#issuecomment-64200554 .

serge-jerkezian commented 9 years ago

ok I added the reference to the model.js, controller.js, and app.js. However, its still not working :(

I checked the output windows (javascript) and all the files are being loaded properly.

jmbledsoe commented 9 years ago

The only thing I can suggest at this point is that you upload your project (or a sample project that demonstrates the "not working") to a spot where I can download it and look further.

On Mon, Nov 24, 2014 at 9:41 AM, rtp-serge notifications@github.com wrote:

ok I added the reference to the model.js, controller.js, and app.js. However, its still not working :(

— Reply to this email directly or view it on GitHub https://github.com/jmbledsoe/angularjs-visualstudio-intellisense/issues/14#issuecomment-64202466 .

serge-jerkezian commented 9 years ago

at this point I don't think i can do that, thank you a lot for trying to help out!

jmbledsoe commented 9 years ago

Closing the issue then.