Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use UpperCase filter in angular?

Is there a way I can do this with Angular Filter? For some reasons I'm not allowed to do it by Javascript ways, and creating additional files is not allowed as well

BTW, the purpose of the codes is to compare the users inputs whatever it is uppercase or lowercase, not just display the varName

<span data-ng-show="varName.toUpperCase() == 'YOURNAME'">
    Aswsome name !</span>

<span data-ng-hide="varName.toUpperCase() == 'YOURNAME'">
    {{varName}} is not my name.</span>

I have tried something like this but failed

<span data-ng-show="varName|uppercase == 'YOURNAME'">
    Aswsome name !</span>
like image 661
Joey Zhang Avatar asked Oct 16 '25 03:10

Joey Zhang


2 Answers

you have to use like this ....

   {{ uppercase_expression | uppercase}}

Example :

   <div ng-app>

    <p>
        <label>Enter your name (in lower case)</label>
        <input type="text" ng-model="yourname" />
    </p>

    <p> {{ yourname | uppercase }} </p>
</div>
like image 84
Glory Raj Avatar answered Oct 18 '25 05:10

Glory Raj


You can convert strings to uppercase with this filter

In HTML Template Binding:

{{ varName | uppercase}}
like image 44
Ali Mamedov Avatar answered Oct 18 '25 03:10

Ali Mamedov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!