Code Monkey home page Code Monkey logo

fusion-messages's Introduction

fusion-messages GitHub version

===

A friendly wrapper for ngMessages.

This directive address a few usability issues with ngMessages.

  1. ngMessages displays all of the error messages for all input fields. fusionMessages only displays an error if the field is dirty or if the form has been submitted.
  2. ngMessages requires you pass the $error object manually. fusionMessages will look this up from the input name.
  3. fusionMessages provides and imperative mechanism for adding validation messages. Helpful for importing third-party validator messages.

Usage

  1. bower install fusion-messages (coming soon!)
  2. add fusion-messages.jpg script to your application
  3. add fusionMessages as a module dependency for your application

Basic Usage

fusionMessages wraps ngMessages. At minimum you can use it to add friendlier message behavior:

<form name="myForm">
  <label for="myEmail">Email Address: </label>
  <input type="email" name="myEmail" ng-model="model.email" required>
  <div fus-messages="myForm.myEmail">
    <div ng-message="required">Field Required</div>
    <div ng-message="email">Invalid Email</div>
  </div>
</form>

Supplying default messages via a controller

With fusMessagesDefaults directive you can assign default messages for an entire form at once.

<script>
  app.controller('MainCtrl', function ($scope) {
      $scope.errorMsgs = {
        'required' : 'field is required',
        'email' : 'invalid email address'
      }
  });
</script>
<form name="myForm" fus-messages-defaults="errorMsgs">
  <label for="myEmail">Email Address: </label>
  <input type="email" name="myEmail" ng-model="model.email" required>
  <div fus-messages="myForm.myEmail"></div>
</form>

Testing

Install all the project dependencies with npm install and bower install and run npm test.

fusion-messages's People

Contributors

corinna000 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.