rneves
rneves

Reputation: 2083

How to use regex to print value on angularjs?

How do I do something like this on a template view?

Example:

{{ field.replace(/ \d*/, "") }}

Where field is a string..

Upvotes: 1

Views: 561

Answers (1)

dfsq
dfsq

Reputation: 193261

You can't use regular expression literals in angular expressions (see docs). It means that the closest you can get is creating a regexp object in controller

$scope.regexp = / \d*/;

and then use it in template:

{{ field.replace(regexp, "") }}

Upvotes: 1

Related Questions