0

Here the Sample Link如何通過angularjs將值傳遞給一個控制器到另一個控制器?

我試着實現模態窗口。我從網上找到一些樣本,並且實施了。

在這裏我添加了模態窗口的示例文件。這工作正常。

我確實需要的是在打開模型窗口時我會調用這個函數。

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

任何一個可以幫助我在這?...

+0

您可以使用服務這一點。 –

+0

你能解釋一下嗎? @ hadiJZ –

+1

可能會幫助你http://stackoverflow.com/questions/20181323/passing-data-between-controllers-in-angular-js –

回答

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

傳遞一個範圍NG-對話的控制器有物業的範圍,你可以與任何對象賦給它,該對象及其可用於對話框控制器的屬性。

實施例 -

$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的對話框中,可以訪問externalTemplate.html中$ scope的所有屬性。

詳細檢查這些ng-dialog scope

相關問題