jQuery Sparkline in a cell in ng-grid using CellTemplate and Directive

可紊 提交于 2019-12-06 11:16:54

Use this celltemplate:

cellTemplate: '<div age-line agedata=row.entity.age></div>'

Note that the values are passed as attributes.

The directive should be:

app.directive('ageLine', function () {
    return {
        restrict: 'A',
        scope: { agedata: '=' },
        link: function (scope, elem) {
            scope.$watch('agedata', function (newval) {
                elem.sparkline(scope.agedata);
            });
        }
    };
});

Also note that you dont need the $., since the element is already an jquery(lite) object.

Here is a working plunker: http://plnkr.co/edit/oDbPp9DGFCGGZF30Bzsi?p=preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!