javascript - Angularjs 中下拉列表 "? string:2 ?"的问题

标签 javascript html angularjs

我正在使用 AngularJs ng-model 来选择下拉值 我正在使用 datatable 对列进行排序。

 <select id="{{user.id}}" ng-model="user.commit" name="options" ng-change="update_commit_level(account.commit , user ,oldValue)" ng-init="oldValue = account.commit">
                        <option value="1">Commit1</option>
                        <option value="2">Commit2</option>
                        <option value="3">Commit3</option>
                      </select>

> 在浏览器检查元素中我得到这个:

enter image description here ?字符串:2?

我也尝试过这种方法,但不起作用......

ng-init = "account.commit = '2'"

enter image description here

最佳答案

当您使用datatable时,该问题与插件有关。之后的插件,如果您需要这两样东西,只需使用 Angular <select>使用 ng-options 以 angularJs 方式标记

<table datatable="ng" class="table">

所以解决方案是使用 ng-options

<select id="{{account.id}}" ng-model="account.commit" ng-options="item.ID as item.Title for item in items" ng-change="update_commit_level(account.commit , account)"></select>

$scope.items = [
      {ID: '', Title: '----Select----'},
      {ID: '1', Title: 'Commit1'},
      {ID: '2', Title: 'Commit2'},
      {ID: '3', Title: 'Commit3'},
    ];

谢谢

关于javascript - Angularjs 中下拉列表 "? string:2 ?"的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36233875/

相关文章:

javascript - 物化模式未显示

javascript - 使用 Javascript 滚动网页,其滚动在页面中间触发

HTML 表格,不同列的水平滚动

javascript - 如何在chrome扩展中从background.js引用popup.html DOM?

angularjs - ng-show指令可以延迟使用吗

jquery - angularjs数据表无法重新初始化表错误

javascript - JSON 的 Ng-Options 问题

javascript - event.returnValue 在 IE7 中给我一个错误

javascript - 通过 jQuery 返回 JSON 响应并重构 HTML 表

javascript - 反序列化 XML 的 jQuery 插件?