From b1a67439374ed01caaa7cbd741580d26833cb544 Mon Sep 17 00:00:00 2001 From: flyher Date: Wed, 17 Jun 2015 18:16:55 +0800 Subject: [PATCH] you can get the input value with jquery,this can solve a page with many select and it create dynamic,they cannot use many ng-model --- script/autocomplete.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/autocomplete.js b/script/autocomplete.js index 377ad0f..3c964da 100644 --- a/script/autocomplete.js +++ b/script/autocomplete.js @@ -111,7 +111,8 @@ app.directive('autocomplete', function() { "class": "", "id": "", "inputclass": "", - "inputid": "" + "inputid": "", + "text":"" }; for (var a in attrs) { @@ -215,6 +216,7 @@ app.directive('autocomplete', function() { // scope.preSelectOff(); if(index !== -1) { scope.select(angular.element(angular.element(this).find('li')[index]).text()); + scope.attrs.text = angular.element(angular.element(this).find('li')[index]).text(); if(keycode == key.enter) { e.preventDefault(); } @@ -248,7 +250,7 @@ app.directive('autocomplete', function() { placeholder="{{ attrs.placeholder }}"\ class="{{ attrs.inputclass }}"\ id="{{ attrs.inputid }}"\ - ng-required="{{ autocompleteRequired }}" />\ + ng-required="{{ autocompleteRequired }}" value="{{attrs.text }}" />\