Skip to content
This repository was archived by the owner on Jan 24, 2019. It is now read-only.
This repository was archived by the owner on Jan 24, 2019. It is now read-only.

Improvements to the mask module #16

@pocesar

Description

@pocesar

Right now the mask module is very limited to simple regexes and digits. Would be nice to have a clearer way to (just brainstorming):

  • Add an option to use regex, might be hard to parse it and display a proper input placeholder
Usage example:

<input ui-mask="/[a-f0-9-]{32}/">
  • Add a optional group of characters
Usage example, using backticks to make it optional:

<input ui-mask="A`-AAA`-999">

Making it able to write B-718 as B-XYZ-819
  • Add a switch-case functionality
Usage example:
<input ui-mask ui-options="{switch: model[0]}" ng-model="model" ui-when="{'1':'(99) 99999-9999',else:'(99) 9999-9999'}">

Then for example, when the mask starts with 1, apply a diferent mask, else, apply
another mask (here in Brazil, the state of São Paulo got phone numbers that are 
(11) 99999-9999 and the rest of states are (21) 9999-9999
  • Make it possible to pass in a function to determine the mask (guess it would fix the above two problems)
Usage example:

<input ui-mask="func()">

[...]
angular.controller('TestCtrl', function($scope){
  $scope.func = function(){
    return function(){
      //(re-)apply mask depending on value, would this be called everytime a model is changed?
    }
  };
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions