-
Notifications
You must be signed in to change notification settings - Fork 6.7k
dialog does not inherit scope of controller #259
Comments
This is by design. The $dialog service does not have any knowledge of what On 23 March 2013 20:47, gnesher [email protected] wrote:
|
@gnesher as @petebacondarwin pointed out this is by design really. What we are trying to do is to treat dialogs the same way as routes in AngularJS. I know that the current API is not ideal and it will probably will go through some changes, so if you've got any suggestions to make it better we are all ears. But the thing is that it should be possible to open a dialog from any place, even from a service where there is no "current scope" and the only thing you can work with is the $rootScope. I acknowledge that the syntax used by the resolve is not ideal but if you've got many objects you can group them together, sth like: resolve: {
dialogsModel: function() {
return //return complex model here;
}
} Going to close this one for now, let's move eventual discussion about API changes to: |
@pkozlowski-opensource I'm sadly not familiar enough with Angularjs so what I'm suggesting might not make sense, but couldn't we just pass an parent scope parameter? if it gets passed the scope is instantiated as a child, otherwise it just get assigned to $rootScope? |
I think you need to rethink what you are doing. If you want to pass On 23 March 2013 22:08, gnesher [email protected] wrote:
|
For those wondering how to make use of the resolve (as I was), the properties passed in the resolve object through the dialog options are available as a dependency in the controller.
in the options will let you access 'dialogsModel' as a dependency in MyPopinCtrl with something like this :
I hope this can help. |
I find the reasoning that a dialog shall have it's own isolated scope a bit strange. |
So like everyone else here I thought for sure that the dialog's scope inherited from the one that created it... That being said I don't need to pass data to the dialogs scope. Rather I need to call a method on the creating scope so that the dialog can update elements on the main scope and have the UI reflect this. How do I accomplish this? |
It seems the dialog $scope does not inherit from the controller which created it.
I'm new to Angularjs, but I'm guessing the fact that the dialog is injected into the html body (and not the containing controller) might be causing this?
edit
I know I can use resolve, but I've got multiple objects that needs to be passed which isn't very comfortable (and slightly counter intuitive assuming I'm creating a scope anyway)
The text was updated successfully, but these errors were encountered: