show select field options dynamically

46 views
Skip to first unread message

Debasish Mohanty-Lincoln

unread,
Oct 28, 2014, 10:32:43 AM10/28/14
to ang...@googlegroups.com
Hi All,

I have been struck while creating select field dynamically inside a ng-repeat. Below is the piece of code I am using.


<div ng-repeat="item in actionLabels">
    
    <!-- Setting select field model dynamically using loop index -->

    <select ng-model="formValues.selectedActionLabelOptions[$index]" 
                ng-options="obj.optionId as obj.optionDescription for obj in actionLabelOptions>
                ng-change="showRespectiveInput()"
            <option value="Select">Select</option>
</div> 

I want to add a condition to ng-options. condition is :

If($index == 0 && optionId == 5) then I don't want to add this option to select field. i.e for the first time when loop executes the 5th option in the select field ll not appear.
I am not sure where to put this condition.

I tried with following piece of code by creating ng-option through ng-repeat:

<option ng-repeat="option in actionLabelOptions" ng-hide="$parent.$index == 0 && option.optionId == 5">

This works fine to generate options for respective rows. i.e for the first row 5th option never comes. But ng-change event is not fired.

Can anyone help me regarding this?

Sander Elias

unread,
Oct 28, 2014, 11:15:19 AM10/28/14
to ang...@googlegroups.com
Hi Debasish,

I'm not sure I can follow what it is you want to accomplish.
can you put a sample in a plunk? That way we can play with it, and you have a better change getting an answer!

Regards
Sander

Debasish Mohanty-Lincoln

unread,
Nov 2, 2014, 10:00:59 PM11/2/14
to ang...@googlegroups.com
Thanks a lot for responding... Btw this issue was is solved :)
--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/JGcXX2VYiGQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.


--
Thanks
Debasish Mohanty

Reply all
Reply to author
Forward
0 new messages