When using $compile on component, why is the scope passed through $parent?
问题 I'm trying to dynamically compile an Angular component using $compile , but the scope isn't passed to the components scope, but to the $parent scope instead. Here is a simple component that binds to a myTitle -attribute and presents it: app.component('myComponent', { bindings: { myTitle: '<' }, template: ` <div> <div>Doesn't work: {{ $ctrl.myTitle}}</div> <div>Works: {{ $parent.$ctrl.myTitle}}</div> </div>` }); Then in the controller (or directive, etc.) I compile it using $compile: app