0

I am trying to set value on text field when row is click but I got the value of row text but I am not able to set value on text field .

here is concept

<li ng-click="rowclick(station)" class="item" ng-repeat="station in data.data | filter:stationCode :startsWith">{{station.stationName+"-("+station.stationCode+")"}}</li>

I right ng-click="rowclick(station)" event when any row is click .But I need to set value whatever is selected ..so first type "b" character in text field here is my code http://codepen.io/anon/pen/KpKyZW

 $scope.rowclick=function(station){
     $scope.stationCode=station.stationCode;
          //  $scope.$apply();
   }

Thannks

1 Answer 1

1

Instead of giving stationCode, give SEARCH.stationCode for the model. The problem is with the scoping. The stationCode that you are setting in rowclick function is not in the same scope as the one that you are expecting

See this modified code: http://codepen.io/anon/pen/zGYPWj

$scope.SEARCH.stationCode is the change that I made. I also initialised $scope.SEARCH = {};

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks great solution..can we hide list after selecting one item
Sure. You can use a flag that holds true when you select (click on) a value and becomes false when the textbox changes - and use that to show/hide the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.