Açısal 1 bileşen ve CMS odaklı yaklaşım için en iyi uygulamayı arıyorum.Bileşen ve cms tahrikli uygulama için AngularJS en iyi uygulama
Birden fazla etiket şablonu oluşturmayı planlıyorum ve bu projenin bir CMS içeriği tarafından yüksek oranda tekrar kullanılabilir ve sürülmesini sağlayan bileşenli bir işlem olmasını istiyorum. Ben bileşenlerin bir ağaç olarak JSON kullanmak ve sadece bu gibi hizmet derlemek $ kullanılarak adım ağaç adım derlemek için planlıyorum
:
angular.module('app.compile', [], function($compileProvider) {
$compileProvider.directive('compile', function($compile) {
return function(scope, element, attrs) {
scope.$watch(
function(scope) {
// watch the 'compile' expression for changes
return scope.$eval(attrs.compile);
},
function(value) {
// when the 'compile' expression changes
// assign it into the current DOM
element.html(value);
// compile the new DOM and link it to the current
// scope.
// NOTE: we only compile .childNodes so that
// we don't get into infinite loop compiling ourselves
$compile(element.contents())(scope);
}
);
};
});
});
http://plnkr.co/edit/MwUjE9l6U5wMkE89kwqY?p=preview
- ben olmadığını bilmek istiyorum Birisi bunu daha önce denediniz ve geribildirimlerini paylaşabilir mi?
- İyi bir çözüm gibi geliyor mu? Bu mevcut en iyi uygulama mı?
$compile
hizmetini kullanmak için bu yöntem performans açısından kötü olabilir mi?