New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular-bind-querystring

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-bind-querystring

Two way binding between scope variables and URL querystring with default values

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

angular-bind-querystring Build Status

Two way binding between scope variables and URL querystring with default values.

Installation

Angular is a peer-dependency of this project so you need to install it separately.

Install with NPM

npm install --save angular-bind-querystring

Install with Bower

bower install --save angular-bind-querystring

Setup

Load the script

Add the dist/angular-bind-querystring.min.js to your HTML file.

Add as dependency

Add bindQuerystring module as a dependency of your Angular app:

angular.module('yourModule', ['bindQuerystring']);

Usage

angular.module('yourModule').controller(function($scope, bindQuerystring) {
  var target = {};
  bindQuerystring({
    target: target,
    properties: ['foo']
  });
});

Then every change on URL querystring or the target object (given the selected properties) will be reflected in both.

Parser and formatter

You can send a parser and/or a formatter function to handle the value serialization:

angular.module('yourModule').controller(function($scope, bindQuerystring) {
  var target = {};
  bindQuerystring({
    target: target,
    properties: ['foo'],
    parser: function(value, property) {
      // parse value from querystring to scope property
      return parseInt(value);
    },
    formatter: function(value, property) {
      // formats value from scope property to querystring
      return '' + value;
    }
  });
});

Parsers and formatters receive the actual value and the name of the property being transformed.

Options

  • target - the object that holds the properties being bound
  • properties - an array of strings naming the properties that should be bound
  • scope (optional) - isn't required, but prevents memory leak over time
  • parser (optional) - function that converts the URL query string to your model
  • formatter (optional) - function that converts your model to the URL query string

Contributing

Any help is appreciated, feel free to open issues and submit pull requests.

Keywords

FAQs

Package last updated on 03 Aug 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