0

My data looks like:

[
            {
                "_id": "531dbf8b9b9fc50000a8d611",
                "active": true,
                "client": {
                    "_id": "531dbf8b9b9fc50000a8d60e",
                    "name": "TR"
                },
                "company_id": "531dbf8b9b9fc50000a8d60c",
                "createdOn": "2014-03-10T13:35:07.313Z",
                "description": "Gentle Action Application Pads",
                "dimensions": {
                    "weight": 22.4
                },
                "lot": [
                ],
                "meta": {
                    "category": "Face",
                    "msrp": 7.75
                },
                "sku": "11002",
                "unit_of_measure": "each",
                "updatedOn": "2014-03-10T13:35:07.314Z"
            },
            {
                "_id": "531dbf8b9b9fc50000a8d612",
                "active": true,
                "client": {
                    "_id": "531dbf8b9b9fc50000a8d60e",
                    "name": "TR"
                },
                "company_id": "531dbf8b9b9fc50000a8d60c",
                "createdOn": "2014-03-10T13:35:07.317Z",
                "description": "Skin Renewal System - Enriched (CA)",
                "dimensions": {
                    "weight": 22.4
                },
                "lot": [
                ],
                "meta": {
                    "category": "Face",
                    "msrp": 321.6
                },
                "sku": "11700CA",
                "unit_of_measure": "each",
                "updatedOn": "2014-03-10T13:35:07.318Z"
            }
        ]

In my view, I have:

 <input type="text" ng-model="receivingSku" placeholder="Locations loaded via $http" typeahead="sku for sku in getSku($viewValue) | filter:$viewValue" typeahead-on-select="selectedSku()" class="form-control">

I need the sku field for each item to be in the typeahead. How can I accomplish this?

Presently, I get an error: Error: matches is undefined

2
  • if you post the code that has matches in it, then it might be easier to find the problem Commented Mar 10, 2014 at 22:09
  • I don't have any code with matches in it. I assume it has something to do with the filter? Commented Mar 10, 2014 at 22:10

1 Answer 1

1

You can loop over your original array and create an array of just SKU's:

var skus = origArray.map(function(e) {
  return e.sku;
});

The new array can be used for typeahead.

PS - I'm not very familiar with typeahead. If typeahead is capable of peeking into objects, you don't need to do this.

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

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.