AngularJS - Clamp

HTML

<div ng-app="app">
    <div ng-controller="ctrl">
        <p text-clamp="3">{{ foo }}</p>
    </div>
</div>

CSS

p {
    width: 200px
}

JavaScript

angular.module('app', [])
    .controller('ctrl', function ($scope) {
    $scope.foo = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum";
})
// adapted from https://github.com/josephschmitt/Clamp.js for AngularJS
.directive("textClamp", ['$log', '$window',

function ($log, $window) {
    var opt = {
        splitOnChars: ['.', '-', '–', '—', ' '] //Split on sentences (periods), hypens, en-dashes, em-dashes, and words (spaces).
    };

    /**
     * Return the current style for an element. Shim for IE
     * @param {HTMLElement} elem The element to compute.
     * @param {string} prop The style property.
     * @returns {number}
     */
    function computeStyle(elem, prop) {
        if (!$window.getComputedStyle) {
            $window.getComputedStyle = function (el, pseudo) {
                this.el = el;
                this.getPropertyValue = function (prop) {
                    var re = /(\-([a-z]){1})/g;
                    if (prop === 'float') {
                        prop = 'styleFloat';
                    }
                    if (re.test(prop)) {
                        prop = prop.replace(re, function () {
                            return arguments[2].toUpperCase();
                        });
                    }
                    return el.currentStyle && el.currentStyle[prop] ? el.currentStyle[prop] : null;
                };
                return this;
            };
        }

        return $window.getComputedStyle(elem, null).getPropertyValue(prop);
    }

    /**
     * Returns the maximum number of lines of text that should be rendered based
 ...