How do I clear a field after selecting a type?
Using ui.bootstrap after you select one of the options provided by typeahead, how do you clear the input value?
http://plnkr.co/edit/yz4EtEJSTVekSemzxagC?p=preview
var app = angular.module("app", ['ui.bootstrap']);
app.controller('createBundle', ['$scope', '$http', '$location',
function($scope, $http, $location){
$scope.products = [{name: 'One'}, {name: 'Two'}];
$scope.bundle = {
name: '',
products: [],
technologies: [],
deliveryMethods: [],
};
$scope.addProduct = function(item, model, label){
$scope.bundle.products.push(item);
}
$scope.resetProducts = function(){
$scope.bundle.products = [];
}
}]);
Html
<input type="text" class="form-control" id="products"
ng-model="tempProduct"
typeahead="product.name for product in products | filter:$viewValue | limitTo:8"
placeholder="Products" typeahead-on-select="addProduct($item, $model, $label)">
Decision
typeahead-on-select="addProduct($item, $model, $label);tempProduct=null"
+3
source to share