derlin / semantic-modals

AngularJS ModalService for the semantic-UI framework.
http://derlin.github.io/semantic-modals/
Apache License 2.0
8 stars 1 forks source link

Same $scope as the controller which is opening the Modal #5

Open lucasbraum opened 7 years ago

lucasbraum commented 7 years ago

Is it possible to pass the controller instance to the Modal so they share the same $scope?

I am opening the Modal from my controller but it is not sharing the same $scope.

Thanks

derlin commented 7 years ago

Currently, no: the modal is always created with its own controller. But you can easily pass data between controllers using the inputs argument in showModal. This same inputs can be manipulated in your modal and the changes will be available in the close callback:

ModalService.showModal( {
      inputs     : {
          sensor: {id: 3, name: "lala"},
         otherData: "something"
      },
      cancelable : true

  } ).then( function( result ){
      console.log( result.inputs.sensor );
      console.log( result.inputs.otherData );     
  });

This should cover most of the usecases.