Consider a scenario where a simple directive is defined as follows:
app.directive('seo', function() {
return {
template: '<meta ng-repeat="tag in data" {{tag.attribute}}="{{tag.name}}" content="{{tag.content}}" />',
scope : {
data: '='
},
restrict: 'A',
replace:true
}
});
This directive automatically generates meta tags based on the provided data:
HTML
<meta seo data="data" />
DATA
[{
attribute : 'name',
content : 'foo',
name : 'image'
},
{
attribute : 'property',
content : 'bar',
name : 'title'
}];
The goal is to output something like this using a template:
<meta class="ng-scope" ng-repeat="tag in data" name="image" content="foo" seo data="data">
<meta class="ng-scope" ng-repeat="tag in data" property="title" content="bar" seo data="data">
How can the attribute be dynamically changed with AngularJS? The current approach of using {{tag.attribute}}
before the equal sign does not seem to be effective.