mardi 5 avril 2016

AngularJS custom filter in ng-repeat condition

I'm struggling to grasp how to make a custom filter. I'm looking for the function to filter by ItemID from a dropdown. This works fine, but I need it to stop filtering if the type is of value 8. This is because I'm changing the dataset where item_typeID does not exist

My current code

<ul ng-repeat="(key, item) in stock | filter: {item_code: searchCode} | filter: {item_name: searchName} | filter: {productID: product} | filter: {companyID: company} |  filter: { item_typeID: type } ">

    <li ng-show="stock_items" >
        <div>Product</div>
        {[{ item.product_name }]}
    </li>
    <li ng-show="stock_items" >
        <div>Item Name</div>
            <a ng-click="openModal(item.itemID)" class="activate_modal" name="modal_window">{[{ item.item_name }]}</a>
    </li>

    <li ng-show="stock_items">
        <div>Item Code</div>
        {[{ item.item_code }]}

    </li>

    <li ng-show="stock_items" >
        <div>Stock level</div>
        {[{ item.total_stock }]}
    </li>

    <li ng-show="stock_items">

        <button ng-click="addItem(item.itemID, key)" ng-disabled="disable_them[key]" style="width:100%;" class="btn-icon add-to-cart">Add</button>

    </li>

Just to let you know I've change the standard {{ tags to {[{ so that I can use the Blade templating in Laravel



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire