WORK IN PROGRESS: search

Hi!

I have a little problem. Could you guys help me out on this one?

In  app/src/search/SearchDirective.js:

First what is working:
+             var footer = ['<a class="share-icon" ',
+                           'ng-href="https://twitter.com/intent/tweet?url={{encodedPermalinkHref}}&text={{encodedDocumentTitle}}">',
+                           '<i class="icon-twitter"></i></a>'].join([]);
+
+             scope.encodedPermalinkHref =
+             encodeURIComponent(gaPermalink.getHref());
+             scope.encodedDocumentTitle =
+             encodeURIComponent(document.title);
+
+             scope.$on('gaPermalinkChange', function(event) {
+               scope.encodedPermalinkHref =
+               encodeURIComponent(gaPermalink.getHref());
+             });
+
+             var footer_template = angular.element(footer);
+             $compile(footer_template)(scope); 

and then:

+               cache: true,
+               footer: footer_template,
+               dataType: config.dataType, 

I can create a footer element and compile it and then link it to my scope.
Fine... Not very nice at the moment but it works.

Now, if I try to use the template method of typeahead.

+               template: function(context) {
+                  var html = options.setResponseTemplate(context);
+                  //var template = angular.element(html);
+                  //$compile(template)(scope);
+                  //console.log(results_template);
+                  //return results_template.html;
+                  return html;
+               }, 

The same method doesn't seem to work. When I try that it seems that my scope is not linked to my element.
(see commented code)

Any idea?