darylrowland / angucomplete

AngularJS Autocomplete Directive
510 stars 281 forks source link

getting text from input #93

Open iraj-jelo opened 9 years ago

iraj-jelo commented 9 years ago

can i get typed text in angucomplete input from my controller when any object is not exist and is not returned ? something like "ng-model"?

flareofghast commented 9 years ago

I would also like to do this, I even tried to get the ng-model="searchStr" but that wasn't available in $scope.

flareofghast commented 9 years ago

OK, so I found a way on how to do this (if you're still after it): I edited angucomplete.js like thus

         scope: {
    15             "id": "@id",
    14             "placeholder": "@placeholder",
    13             "selectedObject": "=selectedobject",
    12             "url": "@url",
    11             "dataField": "@datafield",
    10             "titleField": "@titlefield",
     9             "descriptionField": "@descriptionfield",
     8             "imageField": "@imagefield",
     7             "imageUri": "@imageuri",
     6             "inputClass": "@inputclass",
     5             "userPause": "@pause",
     4             "localData": "=localdata",
     3             "searchFields": "@searchfields",
     2             "minLengthUser": "@minlength",
~    1             "matchClass": "@matchclass",
+ 27               "searchStr": "@searchStr"                   

so at line 26 I added a comma, then at 27 I added searchStr

now in my app I can access it using

$scope.$$childHead.searchStr

it's not elegant but it works.