AngularJS > Filters

lowercase and UPPERCASE in AngularJS

How to format string in lower or upper case in AngularJS?


To format string in lower or upper case in AngularJS, we can use lowercase and uppercase filter respectively.

<div ng-app>
    <div ng-init="members=[{username:'SheoNarayan', address: 'Hyderabad', salary: 500000},{username: 'Munna', address:'Scotland', salary : 659}]">
    </div>
    <h2>Filtered data</h2>
    <ul>
        <li ng-repeat="member in members">
        {{member.username | uppercase}} -
        {{member.address | lowercase}}
    </li>
    </ul>
</div>

In above code snippet, we have initialized a JSON collection using ng-init directive. Next, we are using ng-repeat to repeat the items of the JSON collection. 

Notice the highlighted code, the filter uppercase for username nad lowercase for address has been used separated by "|" (pipe sign).

Output

Filter upper case, lower case in AngularJS

 Views: 10939 | Post Order: 26




Write for us






Hosting Recommendations