Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
angular-ellipsis
Advanced tools
Angular directive to truncate multi-line text to visible height. The end of the visible text is appended with an ellipsis, optional text, and optional click callback function.
To use, copy src/angular-ellipsis.js to your project and rename the included module (which is set to 'exampleApp' at the bottom) to your own module.
bower install hn-angular-ellipsis
npm install angular-ellipsis
We forked this repo to fix bad bower dependencies and also to registered it on bower.
Angular Ellipsis Directive demo page
<p data-ng-bind="paragraphText" data-ellipsis></p>
Custom Ellipsis Symbol
A custom ellipsis string can be used. If this value is set, it will replace the default ellipsis (...). This value will be appended at the end of the truncated text, before a custom append (if included). Example:
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-symbol="--"></p>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more" data-ellipsis-symbol="--"></p>
Custom Append Text
You can include a custom string after the ellipsis by setting the attribute ellipsis-append/data-ellipsis-append on the element. This value may be bound to a scope variable instead of just being a static string. If a scope value is used, the direcive will update the appended text on its update. Only text may be used, not HTML. When rendered in the truncated text, this custom string wrapped in a span tag, and can be styled through CSS as usual. Examples:
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more"></p>
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="scope.appendString"></p>
Custom Append Text Click Function
If a custom append string is included, a function can be executed on the resulting span tag's click. The function must exist within the controller's scope. If an ellipsis append string is not included, the function will not execute (since it has no element to bind to). Example:
<p data-ng-bind="paragraphText" data-ellipsis data-ellipsis-append="read more" data-ellipsis-append-click="onClickFunction()"></p>
Works on modern web browers, which includes any relatively recent version of Chrome, Firefox, Safari, and IE 9+. Although there is no formally-maintained list, mobile device support is quite thorough. I will update cross-browser and device issues if they are entered as issues.
FAQs
Angular directive to truncate multi-line text
We found that angular-ellipsis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.