Grunt plugin for auto-generating Angular $resource services for LoopBack
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-devOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-loopback-angular');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.
},
},
});Type: String
Path to the main file of your LoopBack server (usually app.js).
Type: String
Path to the services file you want to generate, e.g. js/lb-service.js.
Type: String
Default: lbServices
Name for the generated Angular module.
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.
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'
},
},
});See CONTRIBUTING.md