angular.module('igTruncate', []).filter('truncate', function (){
  return function (text, length, end){
    if (text !== undefined){
      if (isNaN(length)){
        length = 10;
      }

      end = end || "...";

      if (text.length <= length || text.length - end.length <= length){
        return text;
      }else{
        return String(text).substring(0, length - end.length) + end;
      }
    }
  };
});

angular.module('igTruncate', []).filter('truncate', function () {
  return function (text, length, end) {
    if (!text) {
      return;
    }
    if (isNaN(length)) {
      length = 10;
    }

    end = end || "...";

    if (text.length <= length || text.length - end.length <= length) {
      return text;
    } else {
      return String(text).substring(0, length - end.length) + end;
    }

  };
});

Fix bug with null values, refractorize code
Fix bug with null values, refractorize code

If null values arrives the plugin crashes, with this little change not happens