ui-select 不 运行 标记 mod 并且无法读取未定义的 属性 'length'

ui-select doesn't run tagging mod and Cannot read property 'length' of undefined

我想 运行 一个 ui-select 用于关键字标签。第一次加载时,当我输入一个新标签时,一切正常,但删除所有标签再次输入标签时出错:

Cannot read property 'indexOf' of undefined

Demo

在您的控制器中初始化 $scope.availableOptions

作者:

app.controller('builder', function($scope) {

  /**
   * default fields
   */

  $scope.availableOptions = []; // <- add this line.

  $scope.newItemNo = 1;
  $scope.finalFields = [];
  $scope.field = {
    'index': $scope.newItemNo,
    title: 'choice1',
    type: 'string',
    length: 20,
    htmlType: 'text',
    validations: [],
    searchable: true,
    fillable: false,
    primary: false,
    show: true,
    select: [],
    radio: [],
    checkbox: 1
  };
});

已修复demo