私はd3jsいくつか.floating-node
をして、それぞれのために作成してい角度1.5.5
でcomponent based appプロジェクトを構築していて、新しいスコープを取得し、の内側に追加コンパイルされたコンポーネント。
nodeEnter.each(() => {
let childScope = this.$scope.$new();
childScope.test = "test";
let compiled = this.$compile('<mycomponent></mycomponent>')(childScope);
(this.mainContainer).append(compiled);
});
完全にコードの仕事のこの部分:
このコードの一部は次のようになり。
そして、これがmycomponent
export default class Mycomponent {
constructor($scope) {
console.log($scope.test); // undefined
console.log($scope.$parent.test); // test
}
}
Mycomponent.$inject = ["$scope"];
あるしかし、私は私のmycomponent
コンポーネントで取得するとき。私は権利を得ることができません$scope
。
私は$id
をチェックしchildScope.$id
がMycomponent
$scope.$id += 1
に私は$scope.$parent
を介して取得することができます知っているが、私は望ましくない$scope
を作成し、それが本当にループに感謝いないことを理解しています。
どのように私は同じを得ることができます$scope
?
あなたは正しいです!だから私は新しい '$ scope'を作成せず、' $ compile'で作成したものを使用しました。しかし、プロンプトは今異なっています。私の新しいスコープを(最初の)コントローラーからどのように入手できますか? –