Javascript 将数据传递给子窗口AngularJs

Javascript 将数据传递给子窗口AngularJs,javascript,angularjs,angular-chart,Javascript,Angularjs,Angular Chart,因此,我对前端开发相对较新,我试图用我创建的angular-chart.js模板打开一个子窗口。现在的问题是,我所拥有的数据似乎也没有传递过来。现在我知道子窗口不能访问父窗口所访问的数据或DOM,但是传递数据的最佳方法是什么?我正在使用角度图表 js: $scope.openLargeGraph = function () { $scope.dataSample = "hi"; console.log(dataSample)

因此,我对前端开发相对较新,我试图用我创建的angular-chart.js模板打开一个子窗口。现在的问题是,我所拥有的数据似乎也没有传递过来。现在我知道子窗口不能访问父窗口所访问的数据或DOM,但是传递数据的最佳方法是什么?我正在使用角度图表

js:

   $scope.openLargeGraph = function () {
                $scope.dataSample = "hi";
                console.log(dataSample)
                var childWindowForGraph = window.open('template.html', "", "width=950,height=850");
               childWindowForGraph.data =
                childWindowForGraph.moveTo(300, 50);
            };
 <div class="col-xs-12 well"
         style="margin-bottom: 6px; padding: 3px; padding-left: 0px;
                max-height: 480px; overflow-y: auto;"
         ng-show="currentSample.viz == 'hbc'">
        <canvas id="panel1base" class="chart-base" height="400px"
                chart-type="'horizontalbar'"
                chart-labels="profile['detail']['freq-histogram'].labels"
                chart-data="[profile['detail']['freq-histogram'].data]"
                chart-legend="false"
                chart-colours="['#008080']"
                chart-legend="false"/>
    </div>
template.html:

   $scope.openLargeGraph = function () {
                $scope.dataSample = "hi";
                console.log(dataSample)
                var childWindowForGraph = window.open('template.html', "", "width=950,height=850");
               childWindowForGraph.data =
                childWindowForGraph.moveTo(300, 50);
            };
 <div class="col-xs-12 well"
         style="margin-bottom: 6px; padding: 3px; padding-left: 0px;
                max-height: 480px; overflow-y: auto;"
         ng-show="currentSample.viz == 'hbc'">
        <canvas id="panel1base" class="chart-base" height="400px"
                chart-type="'horizontalbar'"
                chart-labels="profile['detail']['freq-histogram'].labels"
                chart-data="[profile['detail']['freq-histogram'].data]"
                chart-legend="false"
                chart-colours="['#008080']"
                chart-legend="false"/>
    </div>

这将无法正常工作。您正在尝试加载angular生命周期之外的模板


您应该通过路由访问该模板,并将控制器与其关联。

为什么不能将数据作为变量传递?角度图表作为角度指令工作,这就是为什么您需要一些角度上下文才能调用它。直接调用模板不会为您提供任何角度上下文。我真的很困惑。不用担心,这里有一个包含两条路线的plunkr,解释角度中的基本路线:。为什么我不能将图表库加载到模板中?我在移动数据时遇到了更多问题。