How to bind typeahead selection to input fields

260 views
Skip to first unread message

Rudy Sanchez

unread,
Aug 23, 2014, 9:01:45 PM8/23/14
to ang...@googlegroups.com
I have a modal that is for creating a new Job. There is a typeahead input to search for the related Customer. When I select a Customer from that list I need the properties to populate input fields. I made a plunkr but I can't get the typeahead to work.http://plnkr.co/edit/acUifP4viuu9Whz3ciSW?p=preview
<input type="text" class="form-control" ng-model="CustomerName"
 
typeahead="job.Customers[0].CustomerName for job in jobArray  | filter:$viewValue"
   
placeholder="Enter Customer" typeahead-on-select="selectedCustomer = $item;">


<div class="form-group">
   
<div class="input-group">
     
<span class="input-group-addon">C. Name</span>
       
<input type="text" class="form-control" ng-model="CustomerName"
         
typeahead="job.Customers[0].CustomerName for job in jobArray  | filter:$viewValue"
         
placeholder="Enter Customer" typeahead-on-select="selectedCustomer = $item;">
 
</div>
</div>
<div class="form-group">
   
<div class="input-group">
       
<span class="input-group-addon">C. Address</span>
         
<input ng-model="CustomerAddress" class="form-control" type="text">
   
</div>
</div>


Sander Elias

unread,
Aug 24, 2014, 6:10:50 AM8/24/14
to ang...@googlegroups.com
Hi Rudy,


Witch type-ahead do you want to use? it's not provided by angular, so you need to load one into your plunker before you can use it.
your comprehension expression looks a bit awkward to me, I don't think you are receiving what you expect there.


Regards
Sander

Rudy Sanchez

unread,
Aug 24, 2014, 7:27:45 AM8/24/14
to ang...@googlegroups.com

I'm not sure on that, I have never used it before. After doing some more reading last night I learned that Twitter moved it out of bootstrap and into typeahead.js. and there is angular-ui typeahead that is similar to the old bootstrap version. What is the best way to go on this?

--
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/Y6gzPi72i6Y/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.

Rudy Sanchez

unread,
Aug 24, 2014, 12:41:41 PM8/24/14
to ang...@googlegroups.com
ok, I found a solution.

<div class="input-group">
                                                <span class="input-group-addon">C. Name</span>
                                                <input type="text" class="form-control" ng-model="CustomerName"
                                                       typeahead="customer.CustomerName for customer in customerArray | filter:$viewValue"
                                                       placeholder="Enter Customer" typeahead-on-select="selectCustomer($item)">
                                            </div>

//Typeahead Customer select
    $scope.selectCustomer = function (customer) {
        $scope.CustomerName = customer.CustomerName;
        $scope.CustomerAddress = customer.CustomerAddress;
    };



On Sunday, August 24, 2014 6:27:45 AM UTC-5, Rudy Sanchez wrote:

I'm not sure on that, I have never used it before. After doing some more reading last night I learned that Twitter moved it out of bootstrap and into typeahead.js. and there is angular-ui typeahead that is similar to the old bootstrap version. What is the best way to go on this?

On Aug 24, 2014 5:11 AM, "Sander Elias" <sande...@gmail.com> wrote:
Hi Rudy,


Witch type-ahead do you want to use? it's not provided by angular, so you need to load one into your plunker before you can use it.
your comprehension expression looks a bit awkward to me, I don't think you are receiving what you expect there.


Regards
Sander

--
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/Y6gzPi72i6Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages