From 5a77661d04c2ae4a1df1c0c1622cb30d6e900082 Mon Sep 17 00:00:00 2001 From: swick7 Date: Wed, 20 May 2015 10:28:45 -0500 Subject: [PATCH] docs(guide/Filters): describe your change... I had a really hard time understanding that if I use a custom filter from a controller or service, I needed to add the string "Filter" to the name of the filter when listing it as a dependency of my controller or service. I hope, by adding this example of the custom filter, "name", it becomes apparent. It's weird that a developer could refer to the custom filter by it's name in a view, like `
{{user.name}}
` but they have to refer to it by "nameFilter" from a controller or service instead of just "name". In this example, the error message from angular is really unhelpful when the controller fails to refer to the "name" filter by the string "nameFilter". The error is, "Error: [$injector:unpr] Unknown provider: nameProvider <- name <- FilterController". --- docs/content/guide/filter.ngdoc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/content/guide/filter.ngdoc b/docs/content/guide/filter.ngdoc index 6830cfdea459..dfa98a6f6ef5 100644 --- a/docs/content/guide/filter.ngdoc +++ b/docs/content/guide/filter.ngdoc @@ -64,7 +64,18 @@ or the filter expression is changed). angular.module('FilterInControllerModule', []). - controller('FilterController', ['filterFilter', function(filterFilter) { + filter('name', function () { + return function (names, value) { + var matches = []; + for(var i=0; i