如何在angularjs中检查案例 [英] How do I check the case in angularjs
问题描述
我在HTML选择输入中有两个选项,其值为
Hi,
I have two options in HTML select input with values as
AbhiNAV5
RaviNATH6
用户选择其中一个值并存储在DB中。
如果任何用户直接将DB中的值更改为ABHINAV5或abhinav5或RAVINATH6或ravinath6(或者无论如何他可能想要),
然后我我无法在下拉菜单中显示该值。而是添加一个空白条目
这是HTML
User selects one of these values and that will be stored in DB.
If any user directly changes the value in DB as `ABHINAV5 or abhinav5` or `RAVINATH6 or ravinath6` (or possibly however he wants in any case),
then I am not able to show the value in dropdown. Instead it adds a blank entry
Here is HTML
<select id="Select1" clientidmode="Static" class="htmlDropdown" runat="server" data-ng-disabled="!PropCollection.IsConfigured" data-ng-model="PropCollection.ViewerName" style="width: 150px;" tabindex="2">
<option value="AbhiNAV5">AbhiNAV5</option>
<option value="RaviNATH6">RaviNATH6</option>
</select>
有没有办法处理此案?我希望它不区分大小写。
任何帮助表示赞赏。
谢谢。
我尝试了什么:
我尝试使用过滤器,但没有显示效果。或许我不知道如何以更好的方式使用它。
我试过这个
< select id =Select1 clientidmode =Staticclass =htmlDropdownrunat =serverdata-ng-disabled =!PropCollection.IsConfigureddata-ng-model =PropCollection.ViewerName | filter:falsestyle =width:150px; tabindex =2>
< option value =AbhiNAV5> AbhiNAV5< / option>
< option value =RaviNATH6> RaviNATH6< / option>
< / select>
Is there any way to handle the case? I want it to be case insensitive.
Any help appreciated.
Thanks.
What I have tried:
I tried using filter but it showed no effect. Or perhaps I don't how to use it in a better way.
I tried this as
<select id="Select1" clientidmode="Static" class="htmlDropdown" runat="server" data-ng-disabled="!PropCollection.IsConfigured" data-ng-model="PropCollection.ViewerName | filter: false" style="width: 150px;" tabindex="2">
<option value="AbhiNAV5">AbhiNAV5</option>
<option value="RaviNATH6">RaviNATH6</option>
</select>
推荐答案
嗨Lokesh,
尝试使用ng-options。
假设你的'PropCollection'是一个表格数组:
Hi Lokesh,
Try using ng-options.
assuming your 'PropCollection' is an array of form:
scope.PropCollection = [{ ViewerName: AbhiNAV5},{ ViewerName: RaviNATH6 }];
scope.PropCollection = [{"ViewerName":"AbhiNAV5"},{"ViewerName":"RaviNATH6"}];
你的js文件(或标签)下的
提到以下内容
under your js file (or tag)
mention the following
//to show default value in dropdown controll
scope.viewName = PropCollection [ 0 ]。ViewerName;
scope.viewName = PropCollection[0].ViewerName;
并尝试构建这样的HTML
and try building html like this
<select ng-model="viewName" ng-options="view.ViewName for view in PropCollection">
</select>
现在您可以使用viewName访问所选值。
对于下拉列表,您有一个名为ng-options的预定义指令。
请参阅此plnkr以供参考。
PL unker for ng-Options
这篇关于如何在angularjs中检查案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!