0

I'm getting dynamic data from ajax call which I want to append to a div container with the results from the call but the div is not rendered for some reason.

This is what I have, in the controller:

$http({
   method: 'GET',
   url: '/Search/SearchParts',
   params: { id: id, packageid: $scope.packageid, searchterm: item.SearchValue }
}).success(function (data) {
      $scope.searchresults = data;
});

And then in the html I have this:

<modal title="Search for parts" visible="showSearchForm">
    <div class="container">
        <div class="col-xs-4">
            <div class="row">
                Enter Search Criteria:
                <input type="text" ng-model="item.SearchValue" 
                    class="form-control"/>
            </div>
            <div class="row">
                <button ng-click="searchPart(item)" 
                     class="btn btn-success pull-right">Search Part</button>
                <input type="hidden" 
                     ng-model="$scope.packageid" 
                     id="hfVehiclePackageIdSearchPart"/>
            </div>
            <div class="row" data-ng-repeat="result in $scope.searchresults">
                <label>{{result.linecode}}</label>
            </div>
        </div>
    </div>
</modal>

The last div which has ng-repeat with the data is not being rendered.

Any idea what am I doing wrong?

1
  • What's inside the $scope.searchresults ? can you provide the data ? Commented Dec 23, 2015 at 10:20

2 Answers 2

1

You should not use $scope in you template files you should use like

<div class="row" data-ng-repeat="result in searchresults"><!-- remove $scope -->

You have another line here also

<input type="hidden" 
     ng-model="packageid" <!-- remove $scope -->
     id="hfVehiclePackageIdSearchPart" />
Sign up to request clarification or add additional context in comments.

Comments

0

You don't have to reference $scope in your html.

You can use the models directly like ng-repeat="result in results".

Comments

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.