ng-option not refreshing on model update

3,105 views
Skip to first unread message

Piyush Gupta

unread,
Feb 21, 2013, 3:58:47 PM2/21/13
to ang...@googlegroups.com
Hi,

I am really stuck here.

I am having a complex view where I am having one controller and I get data from service and store model to $scope.

Its a hierarchical object somthing like

MainObject
-prop1
-prop2
-propary
--proparyprop1
--proparyprop2...

on one view ,I use ng-repeat for propary inside which I have a text box and  one dropdown whose option will be populated dynamically based on user input. So on propary , i added one array property and bound it in select using ng-options. Now based on user input on a particular row ,I update  propary but select option dont get updated.To  make sure ,If I am doing everything right , I put a li with ng-repeat at the same place and it gets updated perfectly . To further check, I put a filter on ng-options and I can see that Array values are updates but options are as it is.

I used $apply and everything but no success. Worst part is any other repeater except ng-options will work perfectly fine

I am really stuck and any help will be highly appreciated

Sample Code--

        <tr ng-repeat="DetailUpperObject in MainObject.DetailsUpperData  " >
                              
                    <td>
                       <input type="text"  ng-model="DetailUpperObject.ScreeningPropertyID"  ng-model-onblur ng-change="updatedropdown($index)" /> Note: here I am calling a function 
                        </td>                                                                                                                   
                        <td>
                        <label>{{DetailUpperObject.ScreeningValue}}</label>
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.cls"  />
                        </td>
                        <td>
                   
            <select name="ssss"  ng-model="DetailUpperObject.comp1" ng-options="i.firstName for i in DetailUpperObject.CompOptions" > Note:CompOptions populated but not refreshed
  
                         </select>
                        <input type="text" ng-model="DetailUpperObject.comp1.firstName"  />
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.fam"  />
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.Lot"  />
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.Loc"  />
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.Qty"  />
                        </td>
                        <td>
                        <input type="text" ng-model="DetailUpperObject.Price"  />
                        </td>
                        <td><input type="button" value="delete" ng-hide="MainObject.DetailsUpperData.indexOf(DetailUpperObject)==MainObject.DetailsUpperData.length-1" ng:click="MainObject.DetailsUpperData.splice(MainObject.DetailsUpperData.indexOf(DetailUpperObject), 1)" /></td>                        
                    </tr>
                    
                </table>
    





Richard Vowles

unread,
Feb 21, 2013, 6:19:58 PM2/21/13
to ang...@googlegroups.com
I'm having a similar problem, but only in IE8/9. It looks like I'm going to have to go back jquery for this one.

Piyush Gupta

unread,
Feb 22, 2013, 12:42:55 AM2/22/13
to ang...@googlegroups.com
Hi Richard,

Can you please suggest how to go about this with jquery as generally Angularjs discourages the same.

Clint Checketts

unread,
Feb 22, 2013, 1:33:27 AM2/22/13
to ang...@googlegroups.com
Piyush,

Is this similar to what you are attempting? http://beta.plnkr.co/edit/yLCwSbZIqnMujRr0mB77

-Clint

PS- Feel free to update the plunk to demonstrate your problem, much easier to help if you take that step. Live code make it easier to debug.




--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, 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?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Piyush Gupta

unread,
Feb 22, 2013, 4:25:06 AM2/22/13
to ang...@googlegroups.com
Hi Clint,

Your example seems to be working ass expected but mine is still not working,


I have created a plunker as suggested by you.

Can you please look at this and suggest where am I going wrong.

It will be really helpful as a very critical work has stuck

Piyush Gupta

unread,
Feb 25, 2013, 7:23:45 AM2/25/13
to ang...@googlegroups.com
Hi,

Can somebody please reply if this is a bug or am I doing something wrong here.

In case of a bug...what is the way out.

I have proposed AngularJs in one project and my POC has got stuck only because of this.

Plzzzzzzzzz help!!!!!!!!


Regards,

Piyush Gupta

Pawel Kozlowski

unread,
Feb 25, 2013, 7:26:49 AM2/25/13
to ang...@googlegroups.com
Hi!

2 remarks:

1) You are using very old jQuery (1.4.x) wile the current AngularJS is
tested with 1.9.x
2) Cut down code in your plunker to something < 20 LOC illustrating
essence of your problem and you will have immediately many responses.

Cheers,
Pawel
--
Looking for bootstrap-based widget library for AngularJS?
http://angular-ui.github.com/bootstrap/

Clint Checketts

unread,
Feb 25, 2013, 12:22:23 PM2/25/13
to ang...@googlegroups.com
PIyush,

I'd love to help, but I just don't know where to look.  Like Pawell said, we need to you remove as much code from the plunkr as you can to replicate the error, then give step by step wtat you are typing in and clicking so we know how to see where the mis-beavior is.

-Clint

Piyush Gupta

unread,
Feb 25, 2013, 12:31:42 PM2/25/13
to ang...@googlegroups.com
Hey Pawel....

You are great. Problem was with jquery old version.

Thanks a Ton. 

I somehow  missed this critical  point and paid the price for 3 days.

and sorry for loading everything in plunker but I wanted to exert full scenario.I'll keep that in mind for future problems.

Regards,

Piyush Gupta


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/BCBwWUGv-x8/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Piyush Gupta

unread,
Feb 25, 2013, 12:33:27 PM2/25/13
to ang...@googlegroups.com
Thanks Clint but problem has been solved with Pawell's input.Culprit was old jquery version.

Thanks for the support.

Regards,

--Piyush
Reply all
Reply to author
Forward
0 new messages