bafix2203
bafix2203

Reputation: 541

Filter Search AngularJS

I want to filter in search my catalogs json, but my code doesn't work, here is code :

    <input type="text" style="width:275px;margin-top:5px;" class="form-control form-control-sm form-control-rounded" placeholder="Search..." ng-model="search">

  <br />
  <br />
  <div class="panel-body">
            <div class="cui-ecommerce--catalog">
                <div class="row">
                    <div ng-repeat="(name, text) in textures | filter:search">
                        <div ng-repeat="url in text">
                            <div>
                              {{url.url}}
                                <a href="javascript: void(0);" style="cursor:default;">
                                    <img ng-src="{{url.url }}" />
                                </a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

And my plunker : https://plnkr.co/edit/30nyExfhnLWy35p906CJ?p=preview

Thanks for answers in advance!!!

Upvotes: 1

Views: 49

Answers (1)

K K
K K

Reputation: 18099

Try this alternative approach:

  <div class="panel-body">
        <div class="cui-ecommerce--catalog">
            <div class="row">
                <div ng-repeat="(name, text) in textures">
                    <div ng-if="url.url.indexOf(search||'')>-1" ng-repeat="url in text" >
                        <div>
                          {{url.url}}
                            <a href="javascript: void(0);" style="cursor:default;">
                                <img ng-src="{{url.url }}" />
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

Demo: https://plnkr.co/edit/hxfgKziEAXHJeGjcmg9z?p=preview

Upvotes: 3

Related Questions