我正在尝试学习 AngularJS,并且正在尝试动态编译一些 DOM 元素……我已经尝试过演示:
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);
}
但我得到的只是“未定义$compile”
帮助!