2

I using Angular 1.5.5, and angular-material 1.1.0 here.

When I adding md-chips in ng-repeat loop it do not working, I got follow error:

angular.js:13550 TypeError: this.items.some is not a function
at e.appendChip (http://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js:13:28477)....
  1. md-template do not what that should (as return i go value from md-item-text, which is _id, but i need $chip.text);
  2. it don't addind an item even if i changing md-item-text="item.text" (which is wrong but for test).

It do working well for a single item (with out ng-repeat).

<md-list-item ng-repeat="i in dialogueItems track by $index">
  <md-chips ng-model="i.text" md-removable="true" md-enable-chip-edit="true" md-autocomplete-snap="true" md-require-match="true">
    <md-autocomplete md-min-length="0" md-match-case-insensitive="true" md-selected-item="i.selectedItem" md-search-text="i.searchText" md-items="item in loadItems(i.searchText, i.tagId)" md-item-text="i.selectedItem._id" md-autoselect="true" md-no-cache="true"
    placeholder="Words">
      <span md-highlight-text="i.searchText">{{item.text}}</span>
    </md-autocomplete>
    <md-chip-template>
      {{$chip.text}}
    </md-chip-template>
  </md-chips>
</md-list-item>

JS

$scope.dialogueItems = [{
  tagId: 1,
  text: [],
  searchText: null,
  selectedItem: null
}];
$scope.loadItems = function(query, tagId) {
  return $http({
    method: 'POST',
    url: '/api/wordsapi/searchwords',
    data: {
      text: query,
      tagId: tagId,
      count: 10
    }
  }).then(function(d) {
    return d.data.words;
  });
};

And example of api result:

{
  "words": [{
    "text": "you",
    "_id": "030423b3-99ed-42a2-bab7-7efd10a68cfa"
  }, {
    "text": "i",
    "_id": "a833abe2-c602-4cd7-b765-5b14229ecc7d"
  }, {
    "text": "god",
    "_id": "724766b6-c83c-4679-bf28-827ad1a516eb"
  }, {
    "text": "a",
    "_id": "c2b7920b-7541-42f1-9b61-84a1d7c42930"
  }, {
    "text": "bless",
    "_id": "6ea9b56f-b47b-4453-b97c-0b5ba4311992"
  }, {
    "text": "am",
    "_id": "ab12f90d-9b40-4e33-af13-14e75fbb405a"
  }, {
    "text": "your",
    "_id": "55910a38-4435-4db4-8498-6cddaf4b0059"
  }, {
    "text": "with",
    "_id": "7c5a2627-777f-443e-9f58-83c62e4fae11"
  }, {
    "text": "are",
    "_id": "befa650c-e894-477b-9e67-2f7fb24e40b5"
  }, {
    "text": "good",
    "_id": "90ee8243-630f-4f91-9ecf-0a6469716e0d"
  }],
  "allCount": 1024
}
Rakesh Chand
  • 3,105
  • 1
  • 20
  • 41
SiarheiK
  • 797
  • 4
  • 17

0 Answers0