简体   繁体   中英

AngularJS function parameter hint in webstorm?

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.

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;
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM