Skip to content

agungf/grunt-loopback-angular

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-loopback-angular

Grunt plugin for auto-generating Angular $resource services for LoopBack

Getting Started

This plugin requires Grunt ~0.4.2

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-loopback-angular --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-loopback-angular');

The "loopback_angular" task

Overview

In your project's Gruntfile, add a section named loopback_angular to the data object passed into grunt.initConfig().

grunt.initConfig({
  loopback_angular: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.input

Type: String

Path to the main file of your LoopBack server (usually app.js).

options.output

Type: String

Path to the services file you want to generate, e.g. js/lb-service.js.

options.ngModuleName

Type: String Default: lbServices

Name for the generated Angular module.

options.apiUrl

Type: String Default: The value configured via app.set('restApiRoot') or /api.

URL of the REST API endpoint. Use a relative path if your Angular front-end runs on the same host as the server. Use a full URL including hostname when your Angular application is served from a different address, e.g. when bundled as a Cordova application.

Usage Examples

In this example, our project has the following structure:

 client/      # Angular front-end
   Gruntfile
   js/        # scripts
   css/       # styles
   # etc.
 server/
   app.js       # main app file
   models.json  # loopback models
   # etc.

The configuration will create client/js/lb-services.js file, containing lbServices module talking to the REST endpoint at a path configured in app.js.

grunt.initConfig({
  loopback_angular: {
    options: {
      input: '../server/app.js',
      output: 'js/lb-services.js'
    },
  },
});

Contributing

See CONTRIBUTING.md

About

Grunt plugin for auto-generating Angular $resource services for LoopBack

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors