AngularJS function parameter hint in webstorm?

261 views Asked by At

I'm using OSX 10.10, Webstorm 10.0.4, AngularJS 1.4.3

For example:

.factory('huodai.order.BatchPlanModel', function () {
        var BatchPlanModel = function (date, batches) {
            date = date || "";
            batches = batches || {};
            this.date = date;
            this.batches = batches;
        };
        return BatchPlanModel;
    })

I want when I type var a = new BatchPlanModel() in the controller, some hint about the parameter or documentation shows up. But what did shows up when I press F1 is the definition of the controller. Like:

        ($filter,
         [ optional ] $scope,
         [ optional ] $state,
         $timeout,
         BatchPlanModel,
         BatchPlanFactory,
         EXAMINATION,
         ARRIVE_TYPE )

Parameters:
$filter
$scope
$state
$timeout
BatchPlanModel
BatchPlanFactory

And adding something like

       /**
         * 
         * @param date
         * @param batches
         * @constructor
         */

before the var BatchPlanModel = ... was no help.

2

There are 2 answers

1
charlietfl On

Try changing your component declarations to use declared function references rather than anonymous functions

.factory('huodai.order.BatchPlanModel', batchPlanFactory)

function batchPlanFactory(){
  var BatchPlanModel = function (date, batches) {
            date = date || "";
            batches = batches || {};
            this.date = date;
            this.batches = batches;
        };
        return BatchPlanModel;
}
0
addlistener On

Somehow I can check parameter info not by showing the documentation(pressing F1). There's a Paramter Info section in Preferences. You can set the Autopopup time shorter so you will be notified with the parameter info more quickly.