md联系芯片css不工作

时间:2018-03-07 14:12:05

标签: angularjs-material

我正在使用md联系人芯片,我的模板看起来像这样

 <md-chips ng-model="ser" md-autocomplete-snap
              md-require-match="true">
      <md-autocomplete
        ng-disabled="autoCompleteOptions.isDisabled"
        md-no-cache="autoCompleteOptions.noCache"
        md-selected-item="si"
        md-search-text="searchText"
        md-items="sellable in getSellableByFilter(searchText)"
        md-min-length="1"
        md-item-text="sellable.name"
        placeholder="Search for a Service/Package here"
        md-select-on-match="true",
        >
      </md-autocomplete>
      <md-chip-template>
        <span>
          <strong>{{$chip.name}}</strong>
        </span>
      </md-chip-template>
    </md-chips>

搜索IMG工作正常但是当我选择一个项目时,它看起来只是输入字段而且没有像css这样的芯片。

我该如何解决这个问题?

我也试过使用md接触芯片,但问题仍然存在。

我在控制台中看到

错误消息

angular.js:14800 TypeError: Cannot read property 'some' of undefined
    at MdChipsCtrl.appendChip (angular-material.js:27822)
    at MdChipsCtrl.<anonymous> (angular-material.js:28128)
    at angular.js:1383
    at angular-material.js:25732
    at Array.forEach (<anonymous>)
    at handleSelectedItemChange (angular-material.js:25732)
    at angular-material.js:25694
    at processQueue (angular.js:17169)
    at angular.js:17217
    at Scope.$digest (angular.js:18352) "Possibly unhandled rejection: {}"
(anonymous) @ angular.js:14800
(anonymous) @ angular.js:11218
processChecks @ angular.js:17199
$digest @ angular.js:18352
(anonymous) @ angular.js:18581
completeOutstandingRequest @ angular.js:6428
(anonymous) @ angular.js:6707
setTimeout (async)
Browser.self.defer @ angular.js:6705
$evalAsync @ angular.js:18579
(anonymous) @ angular.js:17041
scheduleProcessQueue @ angular.js:17217
then @ angular.js:17138
getDisplayValue @ angular-material.js:25907
(anonymous) @ angular-material.js:26070
(anonymous) @ angular-material.js:1730
processQueue @ angular-material.js:1727
(anonymous) @ angular.js:20566
completeOutstandingRequest @ angular.js:6428
(anonymous) @ angular.js:6707
setTimeout (async)
Browser.self.defer @ angular.js:6705
timeout @ angular.js:20564
nextTick @ angular-material.js:1711
positionDropdown @ angular-material.js:25453
handleResults @ angular-material.js:26273
handleQuery @ angular-material.js:26251
focus @ angular-material.js:25824
fn @ VM61232:4
callback @ angular.js:27475
$digest @ angular.js:18352
$apply @ angular.js:18649
(anonymous) @ angular.js:27480
dispatch @ jquery.js:5206
elemData.handle @ jquery.js:5014

1 个答案:

答案 0 :(得分:1)

你的模型必须是Array类型,并且可能在你的控制器中你没有将它初始化为任何东西(它是未定义的)。

ser = []