Please be aware that the examples in this blog are no longer valid. For the most current working example please have a look at this example on GitHub.
StrongLoop is pleased to announce the LoopBack AngularJS SDK! This SDK is a set of tools that makes it easy to connect an AngularJS front-end to a LoopBack back-end application over a REST API.
- connect to multiple data sources including Oracle and MongoDB
- write business logic in Node.js
- glue on top of your existing services and data
- Install the Grunt plugin.
- Add the code-generator task to your Gruntfile.
- Run grunt to generate the client code.
- Include the generated file in your web application.
Now you can use the generated services to access your backend via REST.
What is in the SDK?
The SDK has three major components:
- Auto-generated AngularJS services, compatible with ngResource.$resource, that provide client-side representation of the models defined in the LoopBack server.
- A grunt plugin (grunt-loopback-angular) providing a code generator task that can be added to existing Grunt workflows.
- A set of CLI tools (loopback-angular-cli) allowing developers to integrate the code generator into arbitrary workflow.
The SDK is open source and available from npmjs.org:
How does it work?
The code generator (either a Grunt task or the CLI script) loads your LoopBack server application, walks through all models and generates code registering an AngularJS factory for each model.
The factory creates an
ngResource.$resource object, passing in a description of all public methods the model class exposes. This way the resource object provides an API very similar to what you have available in your backend Model class.
The rest of the story is the usual AngularJS as shown in the “Quick Start” section above: you have to configure your client app to include and load the
lbServices module, and tell Angular’s injector which models to use in your code.
See it in action
- Find out more in the LoopBack AngularJS SDK documentation
- Install LoopBack with a simple npm command
- What’s in the upcoming Node v0.12 version? Big performance optimizations, read the blog by Ben Noordhuis to learn more.
- Need performance monitoring, profiling and cluster capabilites for your Node apps? Check out StrongOps! We’ve made it easy to get started with a simple npm install.