Skip to content Skip to sidebar Skip to footer

Assign The Filter Value To A Variable Within A Directive

I am able to do it(title) on my controllers and I was wondering if I can do it on my directives too. Lets say that I inject the filter to my directive like this... app.directive('n

Solution 1:

If you want to use certain filter, you'll have to load it.

Here is the example of defining filter and load into your directive module.

http://plnkr.co/edit/61X6i32By8PA6W7BLh52?p=preview

angular.module('myfilters', []).
filter('i18n', function() {
  returnfunction() { return'my message'; };
});

angular.module('myapp', ['myfilters']).
  directive('ngTest', function($compile, $filter) {
    'use strict';

Post a Comment for "Assign The Filter Value To A Variable Within A Directive"