[英]Convert Jquery Plugin into Angular Directives
I'm having problem when converting my jquery plugin into angular directives, here's my jquery plugin call: 将jquery插件转换为angular指令时遇到问题,这是我的jquery插件调用:
$('#fixed_hdr2').fxdHdrCol({
fixedCols: 0,
width: "100%",
height: 400,
colModal: [
{ width: 50, align: 'center' },
{ width: 110, align: 'center' },
{ width: 170, align: 'left' },
{ width: 250, align: 'left' },
{ width: 100, align: 'left' },
{ width: 70, align: 'left' },
{ width: 100, align: 'left' },
{ width: 100, align: 'center' },
{ width: 90, align: 'left' },
{ width: 400, align: 'left' }
],
sort: true
});
And when I convert it into angular directives it will look like this: 当我将其转换为角度指令时,它将如下所示:
myApp.directive('fixedTable', function () {
return {
restrict: 'AE',
link: function (scope, element, attrs) {
element.fxdHdrCol({
fixedCols: attrs.fixedCols,
width: attrs.width,
height: attrs.height,
colModal: [
{ width: 80, align: 'left'},
{ width: 250, align: 'left'},
{ width: 100, align: 'left'},
{ width: 100, align: 'left'},
{ width: 130, align: 'left'},
{ width: 100, align: 'left'},
{ width: 150, align: 'left'},
{ width: 130, align: 'center'},
{ width: 100, align: 'left'},
{ width: 150, align: 'left'}
]
});
}
}; })
here's my error -> "TypeError: Cannot read property 'width' of undefined" I know I have mistake in converting but I don't know how to convert it correctly. 这是我的错误-> “ TypeError:无法读取未定义的属性'width'”我知道转换时出错,但我不知道如何正确转换。 Any help is very appreciated. 任何帮助都非常感谢。 Thanks 谢谢
your html code? 您的html代码?
Error: "TypeError: Cannot read property 'width' of undefined" 错误: “ TypeError:无法读取未定义的属性'width'”
Possibility 1:width: attrs.width 可能性1:宽度:attrs.width
Possibility 2:colModal and table's column are Inconsistent 情况二:colModal和表的列不一致
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.