Camillia
asked on
Angular- typeahead works but need to change 2 things
I had this question after viewing Angular - following an example but mine partly works.
I used the example in this link for typeahead
http://ryanchenkie.com/typeahead-part-1/
Note: It wasn't working at first. I read the comments at the bottom of that link and typeahead to uib-typeahead.
This works
1. I wanted to make the field non editable. I added typeahead-editable ="false". But I can still make a change to the text.
2. Wanted to add...no results found and followed this example but that didn't work either. I can type an invalid value and I don't see the message
http://plnkr.co/edit/x2lHVztKlQNdYAjZX1CL?p=preview
This link says it's fixed in latest version...middle of the page...but I tried uib-typeahead-editable but I can still type in anything
https://github.com/angular-ui/bootstrap/issues/5801
It has this plnkr.co but this isn't working
https://plnkr.co/edit/gfOCgTY1hHZ8bSQpfFR6?p=preview
Do I need to write onSelect ?
Another solution
This a jsfiddle I found but I can type in the field. Maybe I'm not understandingredients typeahead-editable
http://jsfiddle.net/jLupa/
I used the example in this link for typeahead
http://ryanchenkie.com/typeahead-part-1/
Note: It wasn't working at first. I read the comments at the bottom of that link and typeahead to uib-typeahead.
This works
<input type="text" id="country" name="country" placeholder="country name" ng-model="selectedCountry" uib-typehead ="c as c.Name for c in allCountries | filter: $viewValue | limitTo:3" />
1. I wanted to make the field non editable. I added typeahead-editable ="false". But I can still make a change to the text.
2. Wanted to add...no results found and followed this example but that didn't work either. I can type an invalid value and I don't see the message
http://plnkr.co/edit/x2lHVztKlQNdYAjZX1CL?p=preview
This link says it's fixed in latest version...middle of the page...but I tried uib-typeahead-editable but I can still type in anything
https://github.com/angular-ui/bootstrap/issues/5801
It has this plnkr.co but this isn't working
https://plnkr.co/edit/gfOCgTY1hHZ8bSQpfFR6?p=preview
Do I need to write onSelect ?
Another solution
This a jsfiddle I found but I can type in the field. Maybe I'm not understandingredients typeahead-editable
http://jsfiddle.net/jLupa/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know what I was doing wrong, Julian, that "no results found" wasn't being displayed.
I had typeahead-no-results="noRe sults" in the input tag but I also needed to have something like this to actually display it.
<span ng-if="noResults"> no results found </span>
I had typeahead-no-results="noRe
<span ng-if="noResults"> no results found </span>
That makes sense.
ASKER
I thought it's "built in"...like Kendo Telerik controls I worked with at my previous job. It's not :)
ASKER
I'll take a look at the code again. I'll close this and open another one if I don't get it working the way I want.