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

ng-required-params

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-required-params

Enforce required method parameters in angular

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ng-required-params

A tiny angular module that enforces required parameters on function calls by utilizing ES6 default parameters.

Install

Install using npm or bower:

$ npm install ng-required-params --save
$ bower install ng-required-params --save

ng-required-params has no dependencies other than an ES6 codebase and Angular itself.

Usage

Simply require ng-required-params as a dependency for your app or any angular module.

angular.module('MyApp', ['ng-required-params'])
  .controller('MyController', ['$scope', 'ngRequired', function ($scope, ngRequired) {
      $scope.incrementCounter = (counter = ngRequired`counter`) => {
      	return counter++;
      };
      
      $scope.incrementCounter(); // ==> Error: Missing parameter: counter
  }]);

Since required parameters are fundamental and may be often used, it makes sense to make the call to the service as short and easy-to-type as possible. Therefore it is recommended to use template literal syntax foo´string´ for calling ngRequired instead of the normal round brackets syntax foo('string'). You may also want to import the module as ngReg or req instead of ngRequired to save more keystrokes.

Use with a module loader

If you are using a module loader, you can import the module name when requiring it in angular. This works with any AMD/UMD/CommonJS module loader.

import ngRequiredParamsModule from 'ng-required-params';

angular.module('myModule', [ngRequiredParamsModule.name]);

Keywords

FAQs

Package last updated on 09 Mar 2017

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