2015-02-10 56 views
0

我使用https://github.com/lindell/JsBarcode尝试使用指令就像插入条形码到页面上一个指令:试图让使用JsBarcode

<barcode data=studentData.pid></barcode> 

它得到了相关指令:

.directive('barcode', function() { 
return { 
    restrict: 'EA', 
    scope: { 
      data: '=' 
     }, 
    template: '<canvas id=barcode></canvas>', 
    link: function($scope, element, attrs, ngModel){ 
     canvas = element.find('canvas') 
     JsBarcode(canvas[0], $scope.data); 
    } 

}; 

})

我确定数据正确传递,但JsBarcode库在第46行翻转出来:

var encoder = new window[options.format](content); 

我做了上面的指令,因为我知道你不应该操纵控制器内的DOM作为最佳实践。任何帮助,将不胜感激。

回答

2

我是一个白痴我错过了条形码造型的JS库。 DERP。