ismarslomic / angular-read-more

AngularJS Read More Directive - without jQuery dependency
BSD 3-Clause "New" or "Revised" License
66 stars 44 forks source link

hm-read-more

Build Status Coverage Status Dependency Status

AngularJS directive that limit text and adds read more / read less links to your text when it exeeds certain limit of characters. No requirements to JQuery. Angular animations are used for fade in/out.

Codepen demo

Codepen demo AngularJS Read More

Install client side

$ bower install angular-read-more --save-dev 

Note that angular-sanitize is required since this directive is allowing HTML tags to be used in text.

Run example locally

$ git clone
$ npm install
$ bower install
$ gulp watch

Test locally

$ git clone
$ npm install
$ bower install
$ gulp karma

How to use in HTML

Include JS script

<script src="https://github.com/ismarslomic/angular-read-more/raw/master//cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.6.4/angular-sanitize.min.js"></script>
<script src="https://github.com/ismarslomic/angular-read-more/raw/master/bower_components/angular-read-more/readmore.min.js"></script>

Add the module to your app,

angular.module("app", ["hm.readmore"]);

As element

<hm-read-more
        hm-text="{{ text }}" 
        hm-limit="100" 
        hm-more-text="read more" 
        hm-less-text="read less"
        hm-dots-class="dots"
        hm-link-class="links">
</hm-read-more>

As attribute

<div hm-read-more
        hm-text="{{ text }}" 
        hm-limit="100" 
        hm-more-text="read more" 
        hm-less-text="read less"
        hm-dots-class="dots"
        hm-link-class="links">
</div>

License

angular-read-more is licensed under the MIT license.

Release new Github and Bower version

gulp bump
gulp build
git add .
git commit -m ""
git push

Use Github UI to create new tag and release

Register bower package for the first time

bower register angular-read-more git://github.com/ismarslomic/angular-read-more.git