【问题标题】:Not able to set value to select tag using Angular js无法使用 Angular js 设置值以选择标签
【发布时间】:2014-10-18 08:54:20
【问题描述】:

我的任务很简单。我可以为来自 restful api 的文本框设置值。我可以使用 {{currentCommodity.commodityName}} 获取并显示在原始 HTML 页面上但是,甚至无法为选择标签设置值虽然我能够获得价值。

我的代码是

$scope.editCommodity = function(commodityIndex) {           
        console.log("commodities object",$scope.commoditiesAdded[commodityIndex].commodityName);            
        $scope.currentCommodity.commodityName = $scope.commoditiesAdded[commodityIndex].commodityName;

}

它返回一个带有稻谷的商品名称..

我的 HTML 代码

---{{currentCommodity.commodityName}}-
<select class="form-control selection_size" ng-change="selectunits(currentCommodity.commodityName.commodityID)" ng-model="currentCommodity.commodityName" ng-disabled="{{editBusinessFlag}}" ng-options="commodityitem.commodityName for commodityitem in commodityList">
    </select>

任何帮助将不胜感激。

【问题讨论】:

标签: javascript angularjs


【解决方案1】:

试试下面的代码:

    You selected : {{currentCommodity.commodityName}}
    <select class="form-control selection_size" ng-model="currentCommodity" ng-options="commodityitem.commodityName for commodityitem in commodityList">   
    </select>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-13
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 2018-06-22
    • 1970-01-01
    • 2016-09-26
    • 2014-08-28
    相关资源
    最近更新 更多