Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-formly-transformer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-formly-transformer

Automate configuration of fields in Angular-Formly

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

FormlyTransformer

GitHub version Build Status Coverage Status Codacy Badge Coverage Status

Better way of field transformation in Angular-Formly.

Install

meteor

meteor add wieldo:angular-formly-transformer

npm

npm install angular-formly-transformer

bower

bower install angular-formly-transformer

Getting Started

angular.module('myApp', [
    'formly',
    'formlyTransformer'
  ])

formlyTransformer service

see formlyTransformer API

How to use it

Register transformer

Each transformer has four arguments: fields, model, formOptions, and form.

See fieldTransform in formlyConfig for details.

Transformer is basically the same as fieldTransform method. formlyTransform service just wraps all functions into one place.

formlyTransformer.register(function(fields, model, form, formOptions) {
    // ...
});

Special space in formly field configuration (formlyconfig)

formlyTransformer creates property with "transformers" key and empty object as value.

Special space is removed after all the transformers are executed.

So basically, you can put there all your transformation methods which are based on custom property.

Example

angular.module('myAppName', [
    'formly',
    'formlyTransformer'
  ])
  .run(runApp)
  .controller('demoCtrl', demoCtrl);
  
  function runApp(formlyTransformer) {
        // label upperCaseLabel transformer
        formlyTransformer.register(function(fields) {
            fields.forEach((field) => {
                if(field.transformers.upperCaseLabel && field.templateOptions && field.templateOptions.label) {
                    field.templateOptions.label = field.templateOptions.label.toUpperCase();
                }
            });
        });
  }
  
  function demoCtrl(formlyTransformer) {
        var vm = this;
        
        vm.fields = [
            key: 'firstName',
            type: 'input',
            templateOptions: {
                label: 'First name'
            },
            transformers: {
                upperCaseLabel: true
            }
        ];
        
        console.log(vm.fields[0].templateOptions.label); // FIRST NAME
  }

Bitdeli Badge

Keywords

FAQs

Package last updated on 18 Jan 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc