Skip to content

ng-annotate breaks generated lbServices #29

Closed
strongloop/loopback-sdk-angular
#247

Description

@Evanion

There is a diff in the service names and their annotations in the generated angular code:

module.factory(
  "User",
  ['LoopBackResource', 'LoopBackAuth', '$injector', function(Resource, LoopBackAuth, $injector) {
    var R = Resource(
      urlBase + "/Users/:id",
      { 'id': '@id' },
      {
/// abbreviated for clarity

The service being called in the function parameter is Resource, but it's actual name is LoopBackResource.

The annotation will get replaced by ng-annotate when we run our gulp tasks. thus breaking the module, and causing angular to be unable to find the service, since it's looking for Resource rather than LoopBackResource.

Activity

  1. bajtos commented on Oct 9, 2015

    @bajtos
    Member

    @Evanion thank you for reporting the issue. Could you please contribute a fix yourself?

  2. Evanion commented on Oct 14, 2015

    @Evanion
    Author

    Yea, I will look into it when I have some free time.

  3. luissombra commented on Dec 16, 2015

    @luissombra

    an workaround would be to create a gulp task that replace the word Resource per LoopBackResource. There is a plugin that can do this https://www.npmjs.com/package/gulp-replace.

    The task could looks like this:

    gulp.task('gen:loopback', function () {
      return gulp.src('../my-path/server/server.js')
        .pipe(loopbackAngular())
        .pipe(rename('lb-services.js'))
        .pipe(replace('Resource,', 'LoopBackResource,'))
        .pipe(replace('Resource(', 'LoopBackResource('))
        .pipe(gulp.dest('./src/app/components'));
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions