Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom filter example #3

Open
destegabry opened this issue Jun 14, 2013 · 1 comment
Open

Custom filter example #3

destegabry opened this issue Jun 14, 2013 · 1 comment

Comments

@destegabry
Copy link

I have problems defining a custom filter, now I have a StartFromFilter.js:

define(['Console'], function (Console) {

    "use strict";
    Console.group("Entering StartFromFilter module.");

    var filter = function(input, start) {
        start = +start; //parse to int
        return input.slice(start);
    }

    Console.groupEnd();

    return filter;
});

and my filters.js

define([
  // Standard Libs
  'Console'       // lib/console/console
  , 'Underscore'  // lib/underscore/underscore
  // Application Filters
  , 'filters/StartFromFilter'
], function (Console, _, startFrom){
  "use strict";
  Console.group("Entering Filters module.");

  var filters = {
    startFrom: startFrom
  };
  Console.info("Registered filters: ", filters);

  var initialize = function (angModule) {
    _.each(filters,function(filter,name){
      angModule.filter(name,filter);
    })
    Console.debug("Custom filters initialized.");
  }

  Console.groupEnd();
  return {
    initialize: initialize
  };
});

But I get: Unknown provider: inputProvider <- input <- startFromFilter

@destegabry
Copy link
Author

I have resolved editing StartFromFIlter.js as:

define(['Console'], function (Console) {

    "use strict";

    Console.group("Entering StartFromFilter module.");

    var filter = function(input, start) {
        start = +start; //parse to int
        return input.slice(start);
    }

    Console.groupEnd();

    return function() { 
        return filter; 
    };
});

so the point is return function() { return filter; };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant