How to use Angular JS filter with ICanHaz.js template

77 Views Asked by At

I'm trying to apply an Angular JS filter from within an ICanHaz template... but it doesn't work. Is there a way to do this?

Here's what doesn't work:

<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="ICanHaz.js"></script>

<!-- icanhaz template -->
<script id="a_template" class="partial" type="text/html">
  <div class="whocares">
      {{ variable | angular_filter }}
  </div>
</script>

It doesn't throw any errors, but the variable just doesn't show up. I'm guessing that the problem is that the angular filter doesn't see the variable (or visa versa).

Is there a way to make this work?

1

There are 1 best solutions below

4
Shomz On BEST ANSWER

Not sure why would you complicate things so much, but the quick fix here would be to define a scope variable and use it in a regular angular way:

$scope.variable = "whatever icanhaz outputs";

That way, the filter would be applied to angular controller's scope variable instead of trying to hack in the ICanHaz variable.