9

私は 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 is not defined」だけです

ヘルプ!

4

2 に答える 2