'use strict'; angular.module('wordWrapper', ['tooltip']). directive('wrapEveryWord', ['wrapStringOfWords', function(wrapStringOfWords) { /** * wrap every word in ELEMENT and add tooltip to every word. */ return { restrict: 'A', link: function(scope, elm, attrs) { wrapStringOfWords.traverse(elm[0]) } }; }]). factory('wrapStringOfWords', ['processStringOfWords', function(processStringOfWords) { /** * find all words in the element * @param {DOM element} */ function traverse(elm) { // 1: element node if (elm.nodeType == 1) { for (var i=0; i$&'); } var serviceInstance = { toDom: toDom }; return serviceInstance; }]);