Skip to content

Generate AngularSdk not working using this module #236

Closed

Description

@alvarp

This code:

var generator = require('loopback-sdk-angular');
var fs = require('fs');
var path = require('path');

module.exports = function (app, callback) {
    if(app.booting) {
        app.on('booted', function () {
            console.log('booted');
            generate(app, callback);
        });
    } else {
        generate(app, callback);
    }
};

function generate(app, callback) {
    var options = {
        output: './client/angular-sdk/lb-services.js', // Other task-specific options go here.
        ngModuleName: 'lbServices'
    };

    options.apiUrl = app.get('restApiRoot') || '/api';

    var script = generator.services(app, options.ngModuleName, '/api');

    fs.writeFile(options.output, script, {}, function (err) {
        callback(err);
    });
}

Throws the following error:

undefined:25
      throw err;
      ^

    TypeError: ejs:69
        67|  */
        68|   module.factory(
     >> 69|     <%-: modelName | q %>,
        70|     [
        71|       'LoopBackResource', 'LoopBackAuth', '$injector',
        72|       function(Resource, LoopBackAuth, $injector) {

    meta.ctor.getEndpoints is not a function
        at eval (eval at <anonymous> (D:\User\Documents\projects\project\repo\node_modules\loopback-sdk-angular\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:34:314)
        at eval (eval at <anonymous> (D:\User\Documents\projects\project\repo\node_modules\loopback-sdk-angular\node_modules\ejs\lib\ejs.js:242:14), <anonymous>:110:48)

Activity

  1. self-assigned this
    on Aug 29, 2016
  2. davidcheung commented on Aug 29, 2016

    @davidcheung
    Contributor

    @alvarp what version of loopback are you using? perhaps you are using a new version of sdk-angular with an old version loopback?

  3. alvarp commented on Aug 29, 2016

    @alvarp
    Author

    @davidcheung Loopback 2.26.0

  4. davidcheung commented on Aug 29, 2016

    @davidcheung
    Contributor

    @alvarp looks like the function was added in strong-remoting@2.2.7 since loopback-sdk-angular@1.9.0, you should be able to resolve this would be upgrading your strong-remoting to ^2.27.0+

    /cc @bajtos

  5. bajtos commented on Aug 30, 2016

    @bajtos
    Member

    @davidcheung alternatively, we can modify sdk code-gen to support both API flavours - the new getEndpoints and the old getHttpPath (IIRC the name correctly).

  6. davidcheung commented on Aug 30, 2016

    @davidcheung
    Contributor

    @bajtos lets do that

    alternatively, we can modify sdk code-gen to support both API flavours

  7. changed the title [-]Generate AngularSdk not working using this module [/-] [+]Generate AngularSdk not working using this module[/+] on Sep 15, 2016
  8. davidcheung commented on Oct 11, 2016

    @davidcheung
    Contributor

    Hi @NudgeTech, the fixed has been checked-in(to master) but we have not release to npm yet. in the mean time you could update to strong-remoting@2.32.0 in your loopback application that should fix it.

  9. davidcheung commented on Oct 11, 2016

    @davidcheung
    Contributor

    @NudgeTech
    i believe you should be able to just do npm install strong-remoting --save on your loopback application (if you are using npm3),

    if not you might need to go into node_modules/loopback/ then do npm install strong-remoting --save

    i have not tried this myself, please let me know if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions