I would suggest using scope.$watch() and overwrite your compiled template code. This way, you can make as many requests to the endpoint of the menu as you want, and your template will be recompiled.
Here's more info about the watch: http://docs.angularjs.org/api/ng/type/$rootScope.Scope#$watch
Here's an updated version that should work properly:
return { restrict: 'A', controller: ['$scope', '$q','$http', function ($scope, $q,$http) { $http.get('ajax/menu' ).then(function (data) { $scope.menuHtml = generateHtmlMenu(data); }); }], link: function(scope, element, attr) { scope.$watch('menuHtml', function() { var templateString = scope.menuHtml; var compiledTemplate = $compile(templateString)(scope); compiledTemplate.appendTo("#testD"); }); } }
source share