मैं कोणीय 1 घटक और सीएमएस संचालित दृष्टिकोण के लिए सबसे अच्छा अभ्यास की तलाश में हूं।घटक और सीएमएस संचालित ऐप के लिए AngularJS सर्वोत्तम अभ्यास
मैं कई लेबल टेम्पलेट्स बनाने की योजना बना रहा हूं और मैं चाहता हूं कि यह प्रोजेक्ट घटक संचालित, अत्यधिक पुन: प्रयोज्य और सीएमएस सामग्री द्वारा संचालित हो।
मैं घटकों के एक पेड़ के रूप JSON उपयोग करने के लिए और सिर्फ इस तरह सेवा संकलन $ का उपयोग कर कदम से कदम पेड़ संकलन योजना बना रहा हूँ:
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
- मैं अगर जानना चाहते हैं किसी ने पहले ही यह कोशिश की है और अपनी प्रतिक्रिया साझा कर सकते हैं?
- क्या यह अच्छा समाधान की तरह लगता है? क्या यह सबसे अच्छा अभ्यास उपलब्ध है?
- क्या यह विधि प्रदर्शन के लिए
$compile
सेवा का उपयोग करने के लिए खराब हो सकती है?