app .directive('sparkline', function () { return { restrict: 'A', require: '?ngModel', scope: { options: '=sparkline' }, link: function ($scope, $element, attrs, ngModel) { if (!ngModel) return; var opts = angular.extend({ type: 'bar', barColor: '#ffffff', height: '30px', barWidth: '5px', barSpacing: '2px', zeroAxis: false }, $scope.options); $scope.$watch(ngModel.$viewValue, function () { $element.sparkline(ngModel.$viewValue, opts); }); } }; });