AngularJS intellisense not working on Visual Studio 2015

后端 未结 11 1387
粉色の甜心
粉色の甜心 2020-11-30 01:38

According to this post intellisense should also be working on the new VS 2015, but so far I only get intellisense for the angular object and not for the dependencies or my c

11条回答
  •  青春惊慌失措
    2020-11-30 02:31

    Visual Studio intellisense for AngularJS is extremely sentimental (a nice way of saying that it's most likely poorly developed).

    So, even if everything is well configured with the _references.js file, and you get intellisense for other libraries like jQUERY, you will most probably not get it for AngularJS.

    For example, in VS 2015 community, the below directive will not show intellisense for the $http angular object, although everything works fine with the code:

    In the image below, I add an empty array to the module (which means that the module will get created, and if another with the same name exists, it get overwritten), and intellisense starts working:

    Here is a snippet of the code for you to test yourself (try and add the empty array here):

    (function () {
        'use strict';
    
        angular
            .module('intellisence.sucks.directives')
            .directive('footer', footer);
    
        footer.$inject = ['$http'];
    
        function footer($http) {
    
            $http.
            var directive = {
                link: link,
                restrict: 'EA'
            };
            return directive;
    
            function link(scope, element, attrs) {
            }
        }
    
    })();


    PS: If you click on any folder on you project in the Solution Explorer and press Ctrl+Alt+A to add a new item, you get suggestion to add a AngularJs Directive, and If you do it, the Directive will be like the one I just showed you, without the empty array on the module declaration, so intellisence won't work with it. It won't work with the example that Microsoft gives to the users... Only works on the module creation, your first file and doesn't work from now on.

提交回复
热议问题