I copied this somewhere:
angular.module('app')
.directive('ffInclude', ['$http', '$templateCache', '$compile' ,function($http, $templateCache, $compile) {
return function(scope, element, attrs) {
var templatePath = attrs.ffInclude;
$http.get(templatePath, { cache: $templateCache }).success(function(response) {
var contents = element.html(response).contents();
$compile(contents)(scope);
});
};
}]);
The point of this directive is work like ng-include but without creating a new scope.
It can be used like this:
<div ff-include="my-template.html"></div>
My question is as follows: I would like to use this also for a general template, and in this template I would like to switch out something (an attribute of a html-element).
So if I have this html:
<div ff-include="my-general-template.html" new-attribute-value="false"></div>
And the template could look like this:
<div ng-show="true">Here is some general content</div>
In the directive I should get the attribute like this:
var newAttributeValue = attrs.newAttributeValue;
But how to swap this with new attribute with whatever value is in the ng-show attribute in the template?
Edit: I made a plunk...