我如何将 AngularJs 与 JsBarcode 一起使用?

环R

好吧,如果这有点差,首先抱歉,但这是我的第一个问题。

我正在尝试使用 angular js 使用 JsBarcode 生成条码,但是当我放置像 {{y.code}} 这样的 Angular 代码时,JsBarcode 无法识别,只显示一个空白区域。

$

<html ng-app="myApp">

<script src="https://cdn.jsdelivr.net/jsbarcode/3.6.0/JsBarcode.all.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body ng-controller="myCtrl">

  <div class="row" ng-repeat="y in teste">
    <div class="col center">
      <svg class="barcode" jsbarcode-format="EAN13" jsbarcode-value="978020137962" jsbarcode-textmargin="0" jsbarcode-fontoptions="bold">
</svg>
      <h4>{{y.code}}</h4>
    </div>
  </div>
  \* i thinked in some like this, but doesn't work*\
  <div class="row" ng-repeat="x in teste">
    <div class="col center">
      <svg class="barcode" jsbarcode-format="EAN13" jsbarcode-value="{{y.code}}" jsbarcode-textmargin="0" jsbarcode-fontoptions="bold">
</svg>
      <h4>{{x.code}}</h4>
    </div>
  </div>
  <script>
    $(document).ready(function() {
      JsBarcode(".barcode").init();
    });
  </script>

  <script>
    var app = angular.module("myApp", []);
    app.controller("myCtrl", function($scope) {
          $scope.teste = [

            {

              "item": "1",
              "code": " 978020137962",

            },
            {

              "item": "2",
              "code": "978020137129 ",

            },
            {

              "item": "3",
              "code": " 978020137923",

            },
          });
  </script>

</body>

</html>

娜迦赛A

为了达到预期的结果,使用jsbarcode-value="{{x.code.trim()}}"代替{{y.code}}

问题: y在第二个 div 中未定义,因为 ng-repeat div 在第二个 ng-repeat 开始之前关闭,其中y不可用,只有x.code可用

var app = angular.module("myApp", []);
    app.controller("myCtrl", function($scope) {
          $scope.teste = [

            {

              "item": "1",
              "code": " 978020137962",

            },
            {

              "item": "2",
              "code": "978020137129 ",

            },
            {

              "item": "3",
              "code": " 978020137923",

            },
            ]
          });
<html ng-app="myApp">

<script src="https://cdn.jsdelivr.net/jsbarcode/3.6.0/JsBarcode.all.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body ng-controller="myCtrl">

  <div class="row" ng-repeat="y in teste">
    <div class="col center">
      <svg class="barcode" jsbarcode-format="EAN13" jsbarcode-value="978020137962" jsbarcode-textmargin="0" jsbarcode-fontoptions="bold">
</svg>
      <h4>{{y.code}}</h4>
    </div>
  </div>
  \* i thinked in some like this, but doesn't work*\
  <div class="row" ng-repeat="x in teste">
    <div class="col center">
      <svg class="barcode" jsbarcode-format="EAN13" jsbarcode-value="{{x.code.trim()}}" jsbarcode-textmargin="0" jsbarcode-fontoptions="bold">
</svg>
      <h4>x-{{x.code}}</h4>
    </div>
  </div>
  <script>
    $(document).ready(function() {
      JsBarcode(".barcode").init();
    });
  </script>

</body>

</html>

代码笔 - https://codepen.io/nagasai/pen/XwegrG

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

我如何将ajax与angularJS一起使用?

来自分类Dev

将AngularJS与Liferay一起使用

来自分类Dev

将effekt与angularjs一起使用

来自分类Dev

将AngularJS与npm一起使用

来自分类Dev

如何将AngularJS与SVG标签一起使用?我想从angular传递SVG标签中的参数

来自分类Dev

如何将AngularJS自定义元素与玉一起使用?

来自分类Dev

$ rootScope在AngularJs中无法与我一起使用

来自分类Dev

将OpenLayers与RequireJS和AngularJS一起使用

来自分类Dev

将Angularjs ngBind与javascript对象一起使用

来自分类Dev

强制特定页面将HTTPS与angularjs一起使用

来自分类Dev

将Wijmo事件日历与angularjs一起使用

来自分类Dev

AngularJS:将$ routeProvider与多个模块一起使用?

来自分类Dev

将库(Plyr)与指令和AngularJS一起使用

来自分类Dev

将angularjs $ timeout与$ scope的“ this”一起使用

来自分类Dev

将库(Plyr)与指令和AngularJS一起使用

来自分类Dev

如何更改与angularJS一起使用$ location的URL

来自分类Dev

如何获得联系表格以与angularJS一起使用?

来自分类Dev

如何使AngularJs UI boostrap分页与数据一起使用

来自分类Dev

如何让多行工具提示与 AngularJS 一起使用?

来自分类Dev

我如何将MongoDb与angular一起使用

来自分类Dev

如何从JsBarcode实现生成图像?

来自分类Dev

如何将JsBarcode放在javascript按钮函数中?

来自分类Dev

我可以在AngularJS中将$ q.all与不返回.promise的函数一起使用吗?

来自分类Dev

通过AngularAMD将AngularJS与RequireJS一起使用:无法读取未定义的属性“指令”

来自分类Dev

将Adobe Edge Animate与AngularJS和AngularUI路由器一起使用

来自分类Dev

将Json文件存储在AngularJS变量中以与'ng-repeat'一起使用

来自分类Dev

将AngularJS中的jQueryUI插件与ngRepeat循环中的数据绑定对象数组一起使用

来自分类Dev

将条件运算符与ng-class一起使用-AngularJS

来自分类Dev

将angularJS与requireJS一起使用-无法读取未定义的属性'module'

Related 相关文章

  1. 1

    我如何将ajax与angularJS一起使用?

  2. 2

    将AngularJS与Liferay一起使用

  3. 3

    将effekt与angularjs一起使用

  4. 4

    将AngularJS与npm一起使用

  5. 5

    如何将AngularJS与SVG标签一起使用?我想从angular传递SVG标签中的参数

  6. 6

    如何将AngularJS自定义元素与玉一起使用?

  7. 7

    $ rootScope在AngularJs中无法与我一起使用

  8. 8

    将OpenLayers与RequireJS和AngularJS一起使用

  9. 9

    将Angularjs ngBind与javascript对象一起使用

  10. 10

    强制特定页面将HTTPS与angularjs一起使用

  11. 11

    将Wijmo事件日历与angularjs一起使用

  12. 12

    AngularJS:将$ routeProvider与多个模块一起使用?

  13. 13

    将库(Plyr)与指令和AngularJS一起使用

  14. 14

    将angularjs $ timeout与$ scope的“ this”一起使用

  15. 15

    将库(Plyr)与指令和AngularJS一起使用

  16. 16

    如何更改与angularJS一起使用$ location的URL

  17. 17

    如何获得联系表格以与angularJS一起使用?

  18. 18

    如何使AngularJs UI boostrap分页与数据一起使用

  19. 19

    如何让多行工具提示与 AngularJS 一起使用?

  20. 20

    我如何将MongoDb与angular一起使用

  21. 21

    如何从JsBarcode实现生成图像?

  22. 22

    如何将JsBarcode放在javascript按钮函数中?

  23. 23

    我可以在AngularJS中将$ q.all与不返回.promise的函数一起使用吗?

  24. 24

    通过AngularAMD将AngularJS与RequireJS一起使用:无法读取未定义的属性“指令”

  25. 25

    将Adobe Edge Animate与AngularJS和AngularUI路由器一起使用

  26. 26

    将Json文件存储在AngularJS变量中以与'ng-repeat'一起使用

  27. 27

    将AngularJS中的jQueryUI插件与ngRepeat循环中的数据绑定对象数组一起使用

  28. 28

    将条件运算符与ng-class一起使用-AngularJS

  29. 29

    将angularJS与requireJS一起使用-无法读取未定义的属性'module'

热门标签

归档