0

Here the Sample Link

I tried to Implement Modal window. I find some sample from online and I Implemented.

Here I Added the Sample file for modal window. which is working fine.

what I exactly need is while open the model window I will call this function.

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

Here I Am calling _Product.html and productController from sampleController.

Modal window Invoking from sampleController that time.

How to pass the $scope value of sampleController to productController?

Can any one help me on this?...

Suresh B
  • 1,658
  • 1
  • 17
  • 35
  • you can use service to this. – Hadi J Mar 15 '16 at 05:13
  • can you explain me how? @ hadiJZ – Suresh B Mar 15 '16 at 05:16
  • 1
    may be help you http://stackoverflow.com/questions/20181323/passing-data-between-controllers-in-angular-js – Hadi J Mar 15 '16 at 05:17
  • I don't get your question clearly. If you mean that you need to access the `$scope` variables present in `sampleController` from `productController`, I think that is already done. From your Plunker, I added `$scope.testData = "workingTestData";` under `sampleController` and then added `{{testData}}` in `_Product.html`. When the window opens I was able to see `workingTestData` above the form. – Keerthi Kumar P Mar 15 '16 at 05:28

2 Answers2

1

try this

$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
}]);
Sagar Hirapara
  • 1,677
  • 13
  • 24
0

To pass a scope to controller of ng-dialog there is property scope you can assign it with any object and that object and its properties you can use in dialog's controller.

Example -

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

In above example you have a value object in $scope. In dialog passing the whole $scope so can access all properties of $scope in externalTemplate.html.

For details check these ng-dialog scope

Amit Sirohiya
  • 333
  • 1
  • 13