Ich versuche AngularJS zu lernen, und ich versuche, dynamisch einige DOM-Elemente zu kompilieren ... Ich habe die Demo ausprobiert:
try {
var templateHTML = angular.element('<p>{{total}}</p>'),
scope = ....;
var clonedElement = $compile(templateHTML)(scope, function(clonedElement, scope) {
//attach the clone to DOM document at the right place
});
//now we have reference to the cloned DOM via `clone`
} catch (ex) {
alert(ex.message);
}
aber alles, was ich zurück ist ein "$ compile ist nicht definiert"
HILFE!
Was den Rest Ihres Controller sieht wie, haben Sie in den Controller injizieren kompilieren (zum Beispiel Controller ('MyController', function ($ Kompilierung) {...}). –