Binding TextBox to ng-Repeat

1,075 views
Skip to first unread message

Christian Nwamba

unread,
Aug 15, 2014, 7:55:01 AM8/15/14
to ang...@googlegroups.com
Hi folks
I have this:
<input id="searchCust" type="text" ng-model="meval" class="form-control" />
            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>Contact Name</th>
                            <th>Company Name</th>
                            <th>ID</th>

                        </tr>
                    </thead>
                    {{custo}}
                    <tbody>
                        <tr ng-repeat="cust in customers">
                            <td>{{cust.ContactName}}</td>
                            <td>{{cust.CompanyName}}</td>
                            <td>{{cust.CustomerID}}</td>
                            <td><button ng-click="getcustid()"  class="select-cust-to-sell-to" id="{{cust.CustomerID}}">ddd</button></td>
                        </tr>
                    </tbody>
                </table>
            </div>
i need to set the value of CustomerID to #searchCust textbox.
Please how can i achieve this.
Thanks

Naveen Kohli

unread,
Aug 15, 2014, 11:44:08 AM8/15/14
to ang...@googlegroups.com
<input id="searchCust" type="text" ng-model="cust.CustomerID" class="form-control" />


--
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.
For more options, visit https://groups.google.com/d/optout.



--
Naveen K Kohli
http://www.netomatix.com

Christian Nwamba

unread,
Aug 15, 2014, 3:48:26 PM8/15/14
to ang...@googlegroups.com
The problem is that the text box is not in the ng-repeat. I needed to pass the value once the use clicks on the row


--
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/VcU7_nNA_Bc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Eric Eslinger

unread,
Aug 15, 2014, 4:45:42 PM8/15/14
to ang...@googlegroups.com
put something like selectedCustomerId on the parent scope (I generally have a view object, so I attach stuff like that to view.selectedCustomerId), and then in the getcustid() function, do something like $scope.view.selectedCustomerId = 123

e

Sander Elias

unread,
Aug 16, 2014, 12:50:24 AM8/16/14
to ang...@googlegroups.com

Hi Cristian,

So your goal is to set the meval to the selected customerID? you don’t need a function for that.
try something allong those lines:

  <td><button ng-click="meval = cust.CustomerID" class="select-cust-to-sell-to" id="{{cust.CustomerID}}">ddd</button></td>

Regards
Sander

​
Message has been deleted

Christian Nwamba

unread,
Aug 16, 2014, 7:15:07 AM8/16/14
to ang...@googlegroups.com
Eric thanks. Please i didn't really get your idea. Can you explain the concept with my provided code.

Christian Nwamba

unread,
Aug 16, 2014, 7:59:44 AM8/16/14
to ang...@googlegroups.com
I was able to fix this.

<button class="select-cust" ng-click="getcustid(cust.CustomerID)" id="{{cust.CustomerID}}">ddd</button>

Then my function:
$scope.getcustid = function (val) {
        $scope.meval = val;
    }

Thanks All.
Reply all
Reply to author
Forward
0 new messages