javascript - 如何在AngularJS中将一个 Controller 的值传递给另一个 Controller ?

标签 javascript angularjs angularjs-directive angularjs-scope ng-dialog

Here the Sample Link

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

这里我添加了模式窗口的示例文件。运行良好。

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

$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?

谁能帮我解决这个问题吗?...

最佳答案

试试这个

$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
}]);

关于javascript - 如何在AngularJS中将一个 Controller 的值传递给另一个 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36003115/

相关文章:

javascript - 在指令中编译 Controller 时,AngularJS $scope 未定义

javascript - 带有 UI Bootstrap 指令的 ng-bind-html

javascript - 检查当前日期是否不小于 dd/MM/yyyy 格式的当前日期

java - 如何从 Java applet 线程调用 JavaScript 回调?

javascript - 在 ng-switch-when 上加载外部脚本

angularjs - Angular - ng-hide 与 localStorage 不起作用

javascript - Angular 服务变量未在 View 中更新

javascript - 使用 lodash 对数组进行均匀分块

javascript - AgendaView 中的全日历时间限制渲染

javascript - 如何一起使用继承作用域和隔离作用域