-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
Description
If a remote method is defined in a model's JS file and in its JSON file, if you run lb-ng on the models, the angular sdk outputs an object with duplicate keys(one key from the JSON definition, one from the js implementation). This violates the 'use strict' declaration of the function, and causes the file not to load at all.
"methods": {
"greet": {
"isStatic": true,
"accepts": {
"arg": "msg",
"type": "string"
},
"returns": {
"arg": "greeting",
"type": "string"
},
"description": "Provided a name, returns a greeting ",
"http": [
{
"httpPath": "greet",
"httpVerb": "post"
}
]
}
}
ModelWithRemoteMethod.greet = function(msg, cb) {
cb(null, 'Greetings... ' + msg);
};
ModelWithRemoteMethod.remoteMethod(
'greet',
{
http: {path: '/greet', verb: 'post'},
accepts: {arg: 'msg', type: 'string'},
returns: {arg: 'greeting', type: 'string'}
}
);
Generates this:
https://github.com/cmoore4/loopback-angular-remote-method-duplicate-key-bug-demo/blob/master/client/lb-services.js#L1606-L1643
"greet": {
url: urlBase + "/mwrms/greet",
method: "POST"
},
/**
* @ngdoc method
*/
"greet": {
url: urlBase + "/mwrms/greet",
method: "POST"
},
Removing the method from the JSON definition resolves the issue, but is not optimal.
See demo project here:
https://github.com/cmoore4/loopback-angular-remote-method-duplicate-key-bug-demo
Reactions are currently unavailable