Javascript 为什么Angular将ng范围类放在一个不';我没有附带示波器

Javascript 为什么Angular将ng范围类放在一个不';我没有附带示波器,javascript,angularjs,Javascript,Angularjs,我有一个进行模板转换的jQuery插件,还有一个Angular指令,在插件在生成的DOM节点上运行后通过调用$compile与插件集成: //in the link function of tiFormRender directive element.empty(); compileForm(newForm, tiForms.frameworks(), element); $compile(element.children())(scope); 这将正确处理插件生成的子树中的指令,但出于某种原

我有一个进行模板转换的jQuery插件,还有一个Angular指令,在插件在生成的DOM节点上运行后通过调用$compile与插件集成:

//in the link function of tiFormRender directive
element.empty();
compileForm(newForm, tiForms.frameworks(), element);
$compile(element.children())(scope);
这将正确处理插件生成的子树中的指令,但出于某种原因,它将类
ng scope
添加到编译的模板中:

<div ti-form-render="testForm">
    <md-content class="layout-padding ng-scope layout-row">
        <-- more DOM -->    
    </md-content>
</div>


ti form render
元素(不创建作用域的原始指令)和
md content
元素的作用域与我预期的相同(使用
element.scope()验证)那么为什么Angular要将
ng scope
类附加到一个实际上没有作用域的元素上呢?

ng scope
被添加到任何附加了作用域的元素上(一个作用域可以附加到多个位置),并且由于$compile进程将作用域附加到模板上,它会将该类添加到处理过的模板上。这里看起来有点奇怪,因为它所附加的作用域与父元素相同,这是因为我的黑客解决方案。

您刚刚使用了
$compile
,并将作用域作为参数。为什么不呢?我以为它只添加了创建和附加作用域的类,而不仅仅是附加的。不,据我所知,它被添加到任何绑定中