emersonthis
emersonthis

Reputation: 33378

How to use Angular JS filter with ICanHaz.js template

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?

Upvotes: 0

Views: 74

Answers (1)

Shomz
Shomz

Reputation: 37701

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.

Upvotes: 0

Related Questions