npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-email-list

v1.3.0

Published

Angular.js directive that validates email address in a text area

Downloads

14

Readme

ng-email-list

A angularjs directive that parsers a textarea into an array of valid email addresses.

#Installation

  npm install ng-email-list

You can either self host the script found in dist/ng-email-list.js or use browserify.

<!--self host-->
  <ng-email-list ng-model="emails"></ng-email-list>
  <script scr="/angular.js"></script>
  <script src="/ng-email-list.js"></script>
  ...
  <script>
    //main file
    angular.module('myApp', ['ng-email-list']);
  </script>
  //browserify
  require('ng-email-list');
  angular.module('myApp', ['ng-email-list']);

#Usage

<ng-email-list ng-model="emails"></ng-email-list>

Optional Usage:

<ng-email-list ng-model="model" rejected="rejects" repeat="repeats"></ng-email-list>

If you are using angular 1.3 or greater you can debounce the input:

<ng-email-list ng-model="emails" ng-model-options="{debounce : 1000}"></ng-email-list>

NOTE: If you want your model value to be updated even on invalid input, set the ng-model-options="{allowInvaid: true}"

<ng-email-list ng-model="emails" ng-model-options="{allowInvalid : true}"></ng-email-list>

##Model

Model will be set with an array of valid email address. If the repeat option is specified, it will not contain repeats.

##Rejected (Optional)

An array of invalid email addresses. Perfect for displaying more useful error messages.

##Repeat (Optional) or norepeat

An array of repeated email addresses. Perfect for displaying more useful error messages. WARNING: This feature is incompatible with IE8 or below.

If you do not want an array of repeated emails you can set norepeats.

<ng-email-list norepeat ng-model="emails"></ng-email-list>

<ng-email-list ng-model="emails" repeat="initializedArray"></ng-email-list>

<ng-email-list ng-model="emails" repeat="undefinedVar" norepeat></ng-email-list>

NOTE: arrayOfRepeats must be an empty arry initailized before the directive or you will need to include norepeat.

##Brackets (Optional)

Parser removes all occurrences of < and > before validation.

<ng-email-list ng-model="emails" brackets></ng-email-list>

##Form Validity

If you use the email-list with angulars form validity you get access to the following options: email, repeat, and invalid.

The email error is set if there are one or more invalid emails.

The repeat error is set if there are one or repeated emails. This error will only be set if you set the repeat property. WARNING: This feature is incompatible with IE8 or below.

The invalid error is set if there are invalid or repeated emails. Repeated emails are only check if the repeated property is set.

###Form Validity Example

You can display human friendly error messages in the following manner:

<form name="myForm">
  <email-list name="list" ng-model="emails" rejected="rejects" repeat="repeats"></email-list>
  <div ng-show="inviteForm.list.$error.emailList">
      <p>The email list is invalid!</p>
  </div>
  <div ng-show="inviteForm.list.$error.email">
      <p ng-show="rejects.length === 1">The following email is invalid {{rejects[0]}}</p>
    <p ng-show="rejects.length > 1">The following emails are invalid: {{rejects.join(', ')}}</p>
  </div>
  <div ng-show="inviteForm.list.$error.repeat">
      <p ng-show="repeats.length === 1">The following email is repeated:{{repeats[0]}}</p>
      <p ng-show="repeats.length > 1">The following emails are repeated:{{repeats.join(', ')}}</p>
  </div>
</form>

##Formatters If you set the model (with an array), each email will be formatted in the text area with a new line.

#Developers Guide

Clone this repository and then run npm install.

Building the project use make. This will create the dist files. You will need browserify and uglifyjs installed globally. You can test your dist bundles using the test.html file.

Testing the project use make test. This will run the karma tests.