Böyle bir yönerge yazdım:Açısal'da kök eleman nedir?
app.directive('headersort', function() {
return {
restrict: 'E',
scope: {
sortBy: '=',
title: '='
},
template: '<th>{{ title }}</th>',
replace: true,
link: function (scope, element, attributes) {
scope.sortBy = attributes.sortBy;
scope.title = attributes.title;
}
};
});
Ve bu gibi kullanmak: İstediğim <headersort sortBy="Name" title="Product">
<th>Product</th>
değiştirilir olmasıdır
<headersort sortBy="Name" title="Product">
. Ama bir hata diyerek olsun:
Template must have exactly one root element. was: <th>{{ title }}</th>
Fakat şu, bir kök öğe var mı? Kök elementim <th>
, neden bu hatayı açıyor? Bir kök elemanın koşulları/tanımı nedir?
için HTML değiştirmek, bağlantı işlevi tüm kod, gerekli değildir kapsama beyanı bulunur yüzden. – TheHippo