Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@ angular-dotdotot
================

Angular directive for applying the dotdotdot jquery plugin- http://dotdotdot.frebsite.nl/

Usage:
------
Include the directive in your app (see js/angular-dotdotdot.js).

Then in your controller:

$scope.myText = 'some really long text';

Template:

<p dotdotdot='myText'>{{myText}}</p>
27 changes: 17 additions & 10 deletions js/angular-dotdotdot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
angular.module('dotdotdot-angular', [])
.directive('dotdotdot', function(){
return {
restrict: 'A',
link: function(scope, element, attributes) {
scope.$watch(function() {
element.dotdotdot({watch: true});
});
}
}
});
.directive('dotdotdot', ['$timeout', function($timeout) {
return {
restrict: 'A',
link: function(scope, element, attributes) {

// We must pass in the scope binding, e.g. dotdotdot='myText' for scope.myText
scope.$watch(attributes.dotdotdot, function() {

// Wait for DOM to render
// NB. Don't use { watch: true } option in dotdotdot as it needlessly polls
$timeout(function() {
element.dotdotdot();
}, 400);
});
}
}
}]);