Evaluating a variable inside a string in html angular

I’ve written a service that would let me do a/b testing on my website. For this I must evaluate expressions like these in angular:

<div ng-toggle-test-variant="[['random', 'random2'], [true, {{displayTruth}}]]"

However this gives me a syntax error:

SyntaxError: Unexpected token { 

I’ve tried to do it without {{}} and other ways however I have not been able to make it work.

I do not wish to evaluate this string in my controllers as I would have a lot of extra declaring in the controller for nothing(in my opinion). Could I avoid this somehow?

This is the directive that I’ve written:

/* usage: 
  <div ng-toggle-test-variant="[['random', 'random2'], [true, false]]"> </div>

  the first array is an array that contains the name of the variants for which the element is displayed
  the second array(optional parameter, most of the times it won't be used) will always be composed of 2 elements.
   -> the first element(true) says if it should disregard what the variants say
   -> the second element(false) says if it should display the html element or not

'use strict';

.directive('ngToggleTestVariant', ['$rootScope', function($rootScope) {
  var active_variants = $rootScope.active_variants;
  if (!active_variants) {
    active_variants = ['none'];

  function array_intersect(first_array, second_array){
    var ai=0, bi=0;
    var result = [];

    while( ai < first_array.length && bi < second_array.length ){
     if (first_array[ai] < second_array[bi] ) { ai++; }
     else if (first_array[ai] > second_array[bi] ) { bi++; }
     else {

    return result;

  function inList(active_variants, display_for) {
    var res = false;
    var intersection = array_intersect(active_variants, display_for);
    return (intersection.length == 0 ? false : true)

  return {
    restrict: 'A',
    compile: function(el, attr) {
      var display_for = eval(attr.ngToggleTestVariant || []);
      var overwrite_display = display_for[1] && display_for[1][0]
      function fn(active_variants) {
        var hide = overwrite_display ? display_for[1][1] : !inList(active_variants, display_for);
        el.toggleClass('hide', hide);

      $rootScope.$on("$updateVariant", function() { fn($rootScope.active_variants); });