New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

grunt-loopback-angular-addmodeldata

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-loopback-angular-addmodeldata

Extends grunt-loopback-angular. auto-generating Angular $resource services for loopback will include model data for use at runtime on angular client

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

grunt-loopback-angular-addmodeldata

Extends grunt-loopback-angular. auto-generating Angular $resource services for loopback will include model data for use at runtime on angular client

Getting Started

This plugin requires Grunt ~0.4.5

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-addmodeldata --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-addmodeldata');

The "loopback_angular_addModelData" task

Overview

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

Service.options shown are defaults so you can leave them off if using the same. Should look like

loopback_angular_addModelData: {
      services: {
        options: {
          modelConfig: 'server/model-config.json',
          serviceFile: 'client/app/scripts/lb-services.js',
          modelDir: 'common/models/'
        }
      }
    }

Register task as part of loopback command

grunt.registerTask('loopback', [
    'loopback_angular',
	  'loopback_angular_addModelData', <-- Add this line
    'docular'
  ]);

Usage Examples

So what do you get for this? Now when you access loopback resources in angular you can get at the model info stored in the model.json file. As in

//Supposing you have exposed a customer model on your loopback api
function(Customer) {
	//figure our what properties the customer model has at runtime
	modelProps = Customer.model.properties;
}

I built this because I use angular-formly to automatically generate forms for editing models. By getting access to model properties at runtime and can build out the forms simply based on the fields defined in model.json

Release History

(Nothing yet)

Keywords

gruntplugin

FAQs

Package last updated on 21 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts