1

I am trying to apply the filters on the ng-repeat based on user selection in section options.But unable to do that so far.
Update-It works !! Here's Plunker

HTML

  <div class="container">
  <div ng-include="" src="'refiners.html'"></div>
  <br />
  <br />
  <div class="row">
 <div class="col-xs-12">
      <ul>
        <li ng-repeat="item in data.Results | filter:cc">
          <div>
            <p>{{item.Title}}</p>
            <p>{{item.City}}</p>
            <p>{{item.PostalCode}}</p>
            <span>{{item.MinimumSalePrice | currency}}</span>
            <span>{{item.MaximumSalePrice |currency}}</span>
            <p>{{item.PropertyType}}</p>
            <p>{{item.TenureType}}</p>
          </div>
        </li>
      </ul>
    </div>
5
  • Can you include the code for the cc filter? I realize it's probably in the plunker, but you probably don't want to create extra work for people who may answer your question. Commented Apr 20, 2015 at 1:33
  • i don't have any cc filter . I was trying to do as in jsfiddle.net/MLps6/110 Commented Apr 20, 2015 at 1:38
  • Oh, so you're trying to write a filter. That's not totally clear from your question. Also not clear from your question: what should said filter do? Commented Apr 20, 2015 at 1:42
  • its JSON format. If you see Plunker its there. Based on user selection data should be shown. like if user selected city-Paris.Then data which has city "Paris" should be shown only. Commented Apr 20, 2015 at 1:44
  • Wow, I really misunderstood what you were trying to do. Think I'm on the same page now. You probably want Till Weiss's answer; that seems like the likely solution. Commented Apr 20, 2015 at 1:48

1 Answer 1

1

When you do ng-include you create a new scope so cc is always empty in the parent scope.

This is similar to the issue in this in question. AngularJS - losing scope when using ng-include

You can fix it by adding $scope.cc={} to your controller (creating this element in the parent $scope so the filter has access to it. For this to work you will have to remove the ng-init calls from refiners.html, since these will create a new object in the child scope.

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

1 Comment

Great! Thanks.It works but then how to clear the filter when user selects All form options ?

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.