2

I am getting a JSLint error Bad property name '$promise'. I use AngularJS $resource to save the data. How can I fix the issue?

My code is below:

$ngUser.factory("$userService", [
    "$resource",
    function ($resource) {
        return {
            user: $resource('api/user/', {
                id: '@id'
            }, {
                save: {
                    method: "POST",
                    isArray: false
                }
            })
        };
    }
]);

And I am using the service as:

user = $userService.user.save({
    name: "George"
});
user.$promise.then(function (data) {
    console.log(data);
});

Thanks.

regiea
  • 121
  • 1
  • 5
  • 18

1 Answers1

0

JSLint checks for properties which starts with $ sign. Since most of the frameworks use $ sign as a naming convention for built-in services, it can be ignored.

If you don't want to ignore it, you can use //noinscpetion JSLint in Webstorm or ignore the block of code using JSLint as following:

/*ignore jslint start*/
// block of code
/*ignore jslint end*/ 
Community
  • 1
  • 1
regiea
  • 121
  • 1
  • 5
  • 18