Just an angular.js directive to get reading time of given text
bower install ng-readingtime
or download readingtime.js or dist/ng-readingtime.min.js.
Include the readingtime.js script provided in bower_components and add ngReadingTime
in your app's dependencies.
You can use as directive:
<p>
Reading time: <span ng-reading-time text-to-read="text"></span>
</p>
or as service:
.directive('myCustomDirective', ['readingTime', function(readingTime) {
return {
// ... skipped code
link: function() {
scope.result = readingTime.get(text, {
wordsPerMinute: 210,
format: 'text_only'
});
}
}
}]);
This directive has also two customizable attributes: wordsPerMinute and format. The first represents the words that the user can reads in a minute (default is 210) and the second is the output format. At the moment ng-readingtime supports only 2 formats:
- text_only: string like "readable in 5 minutes and 20 seconds"
- value_only: object with minutes and seconds
- Add internationalization to textual output
- Add graphical output