Skip to content

remcohaszing/angular-rh-format

Repository files navigation

angular-rh-format

Build Status

Introduction

angular-rh-formatting provides simple string formatting in AngularJS. It takes a template string and formats it with the given parameters.

Getting started

  1. Get angular-rh-format in one of the following ways:
  • Using bower:
$ bower install angular-rh-format
  1. Include it in the HTML:
<html>
  ...
  <body>
    ...
    <script src="angular-rh-format/dist/angular-rh-format.js"></script>
  </body>
</html>
  1. Add it as a dependency to your AngularJS app:
angular.module('example', [
  'rh.format'
]);

Usage

As a service:

controller('ExampleCtrl', function($scope, format) {
  $scope.text = format('{person} like {0}', 'beer', {person: 'I'});
});

As a filter:

{{'{person} like {0}'|format:'beer':{person:'I'}}}

About

String formatting in AngularJS

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project