Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, I have created a dirty workaround. Based on the example located here: <a href="https://groups.google.com/forum/#!topic/angular/FqIqrs-IR0w/discussion" rel="nofollow">https://groups.google.com/forum/#!topic/angular/FqIqrs-IR0w/discussion</a>, I have created a new module for the typeahead control:</p> <pre><code>angular.module('storageApp', []).directive('typeahead', function () { return { restrict:'E', replace:true, scope:{ model:'=', source:'&amp;' }, template:'&lt;input type="text" ng-model="model"/&gt;', link:function (scope, element, attrs) { console.log(scope.source); $(element).typeahead({ source:scope.source, updater:function (item) { scope.$apply(read(item)); return item; } }); function read(value) { scope.model = value; } } // end link function }; // end return }); // end angular function </code></pre> <p>I had some issues with the databinding, the auto-fill options are gathered from an Angular control, and I had the issue that the control was created before this information was ready. Therefore, I added an html-attribute (datasource) to the typeahead control, and set up an $observe function in the constructor.</p> <pre><code>&lt;typeahead id="addSupplier" model="addSupplier" placeholder="Skriv inn leverandør" class="typeahead" source="getSuppliers()" &gt;&lt;/typeahead&gt; </code></pre> <p>I think this is a dirty solution, so if anyone has a better idea, I am welcome to hear it :). The bug is described here: <a href="https://github.com/angular/angular.js/issues/1284" rel="nofollow">https://github.com/angular/angular.js/issues/1284</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload