July 15, 2015

Convert Strings from hyphen-notation to camel case Part 2 (AngularJS)

In my last post i demonstrated how to convert Strings from Hyphen Format to CamelCase in Java, using the popular Framework Guava from Google.

In AngularJS this can be achieved using a Regular Expression and an AngularJS Filter.

1) Create a constant function which does the replacement

Our first step is to create a Regular expression which does the conversion from a camel Case Text to Hyphen Format. For reusing purpose we are storing this as a AngularJS constant.

2) Create an AngularJS Filter Function

The second step is to register the constant as a AngularJS Filter. The constant is injected from AngularJS

3) Usage in HTML

We can now use the filter in any Html element, as displayed in the next code snippet.

The following fiddle shows all the examples from this blog post!

Related Posts

Jan Blankenhorn
Developer at thecodecampus </>


Leave a Reply

Add code to your comment in Markdown syntax.
Like this:
`inline example`

```
code block
example
```

Your email address will not be published.