Filter with AngularJs and Gulp

0

I'm creating a filter for the angle using the Gulp compiler however I'm having an error and when parsing the compiled code it looks like it's compiling something wrong, what could it be?

Filter:

class StrSplit extends Filter
  contructor: ->
    return (str, splitChar, splitIndex)->
      return '' unless str
      str.split(splitChar)[splitIndex]

View:

{{mystr | strSplit:',':0}}

Compiled filter:

StrSplit = (function() {
  function StrSplit() {}
  StrSplit.prototype.contructor = function() {
    return function(str, splitChar, splitIndex) {
      if (!str) {
        return '';
      }
      return str.split(splitChar)[splitIndex];
    };
  };
  return StrSplit;
})();
angular.module('ng-utils').filter('strSplit', [StrSplit]);

Error encountered:

  

Can not interpolate:   2 - {{text_filter | strSplit: ',': 0}}   TypeError: Can not read property 'apply' of undefined

    
asked by anonymous 27.03.2015 / 14:05

1 answer

1

Looks like "constructor" is incorrect.

class StrSplit extends Filter
  constructor: ->
    return (str, splitChar, splitIndex) ->
      return '' unless str
      str.split(splitChar)[splitIndex]
    
27.03.2015 / 15:27