2017-02-22 16:18
浏览 33


I am new to angular.js but I am trying to learn. I created a form that allows me to search using a barcode scanner and I can then press a button to submit. This step seems redundant. I would like the scanner to search and then submit the information in one action but I am not sure how to do this. Here is the current code.

<div class="row" ng-controller="SearchItemCtrl">

    <div class="col-md-3">
        <label>{{trans('sale.search_item')}} <input ng-model="searchKeyword" class="form-control"></label>

        <table class="table table-hover">
            <tr ng-repeat="item in items  | filter: searchKeyword | limitTo:10">

                <td><button class="btn btn-success btn-xs" type="button" ng-click="addSaleTemp(item, newsaletemp)"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span></button></td>


图片转代码服务由CSDN问答提供 功能建议

我是angular.js的新手,但我正在努力学习。 我创建了一个表单,允许我使用条形码扫描仪进行搜索,然后我可以按一个按钮进行提交。 这一步似乎是多余的。 我希望扫描仪搜索,然后在一个动作中提交信息,但我不知道如何做到这一点。 这是当前代码。

 &lt; div class =“row”ng-controller =“SearchItemCtrl”&gt; 
&lt; div class =“col-md  -3“&gt; 
&lt; label&gt; {{trans('sale.search_item')}}&lt; input ng-model =”searchKeyword“class =”form-control“&gt;&lt; / label&gt; 
 \  n&lt; table class =“table table-hover”&gt; 
&lt; tr ng-repeat =“item in items | filter:searchKeyword | limitTo:10”&gt; 
&lt; td&gt; @ {{item  .item_name}}&lt; / td&gt; 
&lt; td&gt;&lt; button class =“btn btn-success btn-xs”type =“button”ng-click =“addSaleTemp(item,newsaletemp)”&gt;&lt;  span class =“glyphicon glyphicon-share-alt”aria-hidden =“true”&gt;&lt; / span&gt;&lt; / button&gt;&lt; / td&gt; 
&lt; / tr&gt; 
&lt; / table&gt  ; 
&lt; / div&gt;  
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douqiong8412
    douqiong8412 2017-02-22 17:19

    Does your scanner send a return after the string? I know some scanners have this ability, you could then likely add a ngKeyPress or ngChange attribute to detect the new line command to "auto submit". If the scanner is not able to do this, another option (assuming all UPC codes will have the same length) is to check for the length of the text and auto submit when it reaches the appropriate number of characters for the UPC.

    点赞 评论