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

标签 javascript angularjs angularjs-directive tags ui-select

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

Cannot read property 'indexOf' of undefined

Demo

最佳答案

在 Controller 中初始化 $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 .

关于javascript - ui-select 不运行标记 mod 并且无法读取未定义的属性 'length',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37276916/

相关文章:

jquery - ng-mouseover 不起作用

javascript - 为什么我的ajax成功数据没有显示在Angular JS中

javascript - NVD3 LineChart : Some xAxis dates do not show at the beginning and end of the axis, 尽管我使用的是 tickValues() 方法

javascript - 选中复选框后如何验证我的表单字段?

javascript - Angular 错误: $parse:ueoe Unexpected End of Expression for a couple of expressions

javascript - AngularJS指令如何在条件下显示/隐藏自定义(附加)元素

angularjs - Angular Controller 方法给出了较旧的范围值

javascript - 禁用时如何发布复选框值

javascript - 在段落列表后插入图像列表

angularjs - $state.go() 后侧菜单不起作用 - ionic