angularjs - Angular almighty autocomplete -


im trying alter almighty autocomplete accept array of objects instead of array of strings. sadly, @ standstill.

here want array contain objects instead of strings in app.js

movieretriever.getmovies = function(i) { var moviedata = $q.defer(); var movies;  var moremovies = [{id: "0", name: "somemovie"}, {id: "1", name: "anothermovie"}, {id: "2", name: "amovie"}];  // var moremovies = ["the wolverine", "the smurfs 2", "the mortal instruments: city of bones"]  if(i && i.indexof('t')!=-1)   movies=moremovies; else   movies=moremovies;  $timeout(function(){   moviedata.resolve(movies); },1000);  return moviedata.promise 

but when that, punished errors like

error: [$sce:itype] http://errors.angularjs.org/1.2.12/$sce/itype?p0=html

which suspect origins area in autocomplete.js

template: '\     <div class="autocomplete {{ attrs.class }}" id="{{ attrs.id }}">\       <input\         type="text"\         ng-model="searchparam"\         placeholder="{{ attrs.placeholder }}"\         class="{{ attrs.inputclass }}"\         id="{{ attrs.inputid }}"/>\       <ul ng-show="completing">\         <li\           suggestion\           ng-repeat="suggestion in suggestions | filter:searchfilter | orderby:\'tostring()\' track $index"\           index="{{ $index }}"\           val="{{ suggestion }}"\           ng-class="{ active: ($index === selectedindex) }"\           ng-click="select(suggestion)"\           ng-bind-html="suggestion | highlight:searchparam"></li>\       </ul>\     </div>' 

and here

app.filter('highlight', ['$sce', function ($sce) { 

i meant paste more code here, editor plays tricks on me. , being first question, have leave @ that.

please follow link in top full code example, , see if can me

just question: why don't use http://angular-ui.github.io/bootstrap/#/typeahead

<h4>custom templates results</h4> <pre>model: {{customselected | json}}</pre> <input type="text" ng-model="customselected" placeholder="custom template" typeahead="state state.name state in stateswithflags | filter:{name:$viewvalue}" typeahead-template-url="customtemplate.html" class="form-control"> 

i think cleaner/easier you. http://plnkr.co/edit/?p=preview


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -