🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

ng-valid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-valid

An AngularJS directive to trigger a method when an input is valid (or invalid).

1.0.0
latest
Source
npm
Version published
Weekly downloads
21
200%
Maintainers
1
Weekly downloads
 
Created
Source

ngValid

An AngularJS directive to trigger a method when an input is valid (or invalid).

The problem

This inside a controller:

if (form.inputName.$valid) {
    doSomething()
}

and also this:

$scope.$watch('inputName', function(value) {
    if (isValid(value)) {
        doSomething()
    }
});

The solution

<input type="text" ng-model="inputName" ng-valid="doSomething()" required>

How to install it

  • Bower:
bower install --save ng-valid
  • HTML:
<script src="bower_components/angular.js"></script>
<script src="bower_components/ng-valid/dist/ng-valid.min.js"></script>
  • AngularJS:
var app = angular.module('app', ['ngValid']);

How to use it

Just add the ng-valid attribute and a method to be called when the input is valid:

<input type="text" ng-model="inputName" ng-valid="doSomething()" required>

You can also add the optional attribute ng-invalid to invoke a method when the input is not valid:

<input type="text" ng-model="inputName" ng-valid="doSomething()" ng-invalid="doSomethingElse()" required>

License

See the LICENSE file.

Keywords

AngularJS

FAQs

Package last updated on 10 Oct 2015

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