简体   繁体   中英

ngx-barcode not working with dynamic value in Angular

I am trying to use ngx-barcode in Angular page. When I try to use this code in app.component.html, it works.

But when I try to use the same code in subcomponent, which is opened via window.open with some parameters, it does not work.

<ngx-barcode [bc-value]="value" [bc-display-value]="true">

But in the same page if I create ngx-barcode with static value like below, it works. In summary ngx-barcode with dynamic value not work in subcomponent. Why is this happening?

 <ngx-barcode _ngcontent-qeq-c152="" ng-reflect-value="1234567" ng-reflect-display-value="true">
  <div class="barcode"><svg width="200px" height="142px" x="0px" y="0px" viewBox="0 0 200 142"
      xmlns="http://www.w3.org/2000/svg" version="1.1" style="transform: translate(0,0)">
      <rect x="0" y="0" width="200" height="142" style="fill:#ffffff;"></rect>
      <g transform="translate(10, 10)" style="fill:#000000;">
        <rect x="0" y="0" width="4" height="100"></rect>
        <rect x="6" y="0" width="2" height="100"></rect>
        <rect x="12" y="0" width="6" height="100"></rect>
        <rect x="22" y="0" width="2" height="100"></rect>
        <rect x="26" y="0" width="4" height="100"></rect>
        <rect x="34" y="0" width="6" height="100"></rect>
        <rect x="44" y="0" width="2" height="100"></rect>
        <rect x="52" y="0" width="2" height="100"></rect>
        <rect x="56" y="0" width="4" height="100"></rect>
        <rect x="66" y="0" width="6" height="100"></rect>
        <rect x="78" y="0" width="2" height="100"></rect>
        <rect x="82" y="0" width="4" height="100"></rect>
        <rect x="88" y="0" width="6" height="100"></rect>
        <rect x="96" y="0" width="2" height="100"></rect>
        <rect x="100" y="0" width="8" height="100"></rect>
        <rect x="110" y="0" width="6" height="100"></rect>
        <rect x="118" y="0" width="4" height="100"></rect>
        <rect x="124" y="0" width="6" height="100"></rect>
        <rect x="132" y="0" width="6" height="100"></rect>
        <rect x="140" y="0" width="6" height="100"></rect>
        <rect x="148" y="0" width="4" height="100"></rect>
        <rect x="154" y="0" width="4" height="100"></rect>
        <rect x="164" y="0" width="6" height="100"></rect>
        <rect x="172" y="0" width="2" height="100"></rect>
        <rect x="176" y="0" width="4" height="100"></rect><text style="font: 20px monospace" text-anchor="middle"
          x="90" y="122">1234567</text>
      </g>
    </svg></div>
</ngx-barcode>

Are the both components declared in the same module?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM