What you’re looking for in Angularjs is called filter
.
A filter
takes an input value and optional configuration parameters, and returns a value that will be effectively displayed in the interface.
A filter
is established as follows:
angular.module('MeuModulo', []).filter('nomeDoFiltro', function() {
return function(input, arg1, arg2) {
var out;
// manipula input e seus argumentos...
return out;
};
});
For example, a filter that transforms a string into uppercase
when parameter is true
, and in lowercase
when the parameter is false
:
angular.module('MeuModulo', []).filter('case', function() {
return function(input, uppercase) {
var out = "";
if ( uppercase ) {
out = input.toUpperCase();
} else {
out = input.toLowerCase();
}
return out;
};
});
This filter can then be used in your HTML:
<p>{{ 'minha string' | case:true }}</p>
Echoing after processed by Angularjs:
<p>MINHA STRING</p>
See more about creating filters in the Angularjs documentation:
Developer Guide: Filters
Creating the filter for the CNPJ is a workout!
You cannot format with Jquery?
– PauloHDSousa
Hi @Paulohdsousa all project is already in Angularjs, do in Jquery would be my last option. Thanks
– Claudia Mardegan
You can apply to Mask
ui-br-cnpj-mask
input with angular-ui-inputs> https://github.com/assisrafael/angular-input-masks.– Eduardo Silva
@Eduardosilva I have already applied a mask, <input ng-model="data.cnpj" type="tel" ui-Mask="99.999.999/9999-99" ng-click="inserts
– Claudia Mardegan