Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form ng-submit="addAssignment(assignName)">
- <div class="input-append">
- <input type="text" placeholder="Type a name" ng-model="assignName" ng-change="dostuff()" data-provide="typeahead" data-source="{{ teamNames }}">
- <button class="btn" type="submit">Add</button>
- </div>
- </form>
- $scope.addAssignment = function(name) {
- alert(name);
- return;
- }
- angular.module('storageApp', []).directive('typeahead', function () {
- return {
- restrict:'E',
- replace:true,
- scope:{
- model:'=',
- source:'&'
- },
- template:'<input type="text" ng-model="model"/>',
- 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
- <typeahead id="addSupplier" model="addSupplier" placeholder="Skriv inn leverandør" class="typeahead" source="getSuppliers()" ></typeahead>
Add Comment
Please, Sign In to add comment