0

这里是示例链接

我试图实现模态窗口。我从网上找到了一些示例并实施了。

在这里,我添加了模态窗口的示例文件。这工作正常。

我真正需要的是在打开模型窗口时我会调用这个函数。

$scope.callType = {};
$scope.dataFormDialog = function (id) {
    $scope.callType.id = id;
    exDialog.openPrime({
        scope: $scope,
        template: '_Product.html',
        controller: 'productController',
        width: '450px',
        //animation: false,
        //grayBackground: false            
    });
}; 

这里我从 sampleController 调用 _Product.html 和 productController。

模态窗口当时从 sampleController 调用。

如何将 sampleController 的 $scope 值传递给 productController?

谁可以帮我这个事?...

4

2 回答 2

1

尝试这个

$scope.dataFormDialog = function (id) {
    $scope.callType.id = id;
    exDialog.openPrime({

        template: '_Product.html',
        controller: 'productController',
        width: '450px',
        resolve: {
                   Scopevariable: function () {
                   return $scope;
                  }
        //animation: false,
        //grayBackground: false            
    });
}; 


app.controller('productController', ["Scopevariable",
function (Scopevariable)
{
    // use  Scopevariable
}]);
于 2016-03-15T05:24:08.360 回答
0

要将范围传递给 ng-dialog 的控制器,您可以将属性范围分配给任何对象,并且您可以在对话框的控制器中使用该对象及其属性。

例子 -

$scope.value = true;
ngDialog.open({
    template: 'externalTemplate.html',
    className: 'ngdialog-theme-plain',
    scope: $scope
});

<script type="text/ng-template" id="externalTemplate.html">
   <p>External scope: <code>{{value}}</code></p>
</script>

在上面的示例中,您在 $scope 中有一个值对象。在传递整个 $scope 的对话框中,可以访问 externalTemplate.html 中 $scope 的所有属性。

有关详细信息,请检查这些ng-dialog 范围

于 2016-03-15T05:39:36.473 回答