I'm struggling to find the right way to use one controller as well as a corner-strap model .
Yes, the calling code can be injected into the $ diameter
, so it can be available for the model. But there are problems in it.
myModal = $ modal ({scope: $ area, template: 'template.html', show: wrong, backdrop: "static", keyboard: wrong, continuous: true
});
This will pollute the calling controller with potentially only model-only methods and properties.
I usually use "controller AS", and therefore there is no $ radius
for injection in the model at first place!
You can create a new $ scope
and then insert the methods into it, but again, in the parent controller, $ scope
Bad injuries will need injection bad.
If I use ng-controller
inside the model template, then I can make my controller. But he gives me another problem: now I can not inject the data into the modal controller, and there is no way to know my calling code when the modal closes and returns data from the modal, it also works (To keep the factory only
Any ideas?
Cheers
Update
In this way I am doing it for now:
In my template I give a command which opens the modal Example:
My-Model on-update = "ctrl.OnDialogUpdate">
So basically the command calls to my model and when the modal closes or wants to go back with the result, it calls the method specified in the directive parameter.
How this command might look:
('' Use strict ''; angular module ('app'). Instructions ('MyMold', MyModal); myModal function; Return Note: Modal callback specified in the 'e', // directory tag area: {onUpdate: '& amp;?}}, Replace: true, // This is a template for this: Directive, not modal template url:' button. Html ', controller AS:' ctrl ', bindtoke controller: true, compiled: function (element, ethers) {return function (scope, element, ethers) {};}, / * @ ng inject * / controller: function ($ Radius, $ log, $ different) {var itself = this; Var myDialog = $ aside ({// dialog template template: 'my-modal.template.html', show: wrong, animation: 'Am-fade-and-slide-right', placement: 'right', background: true Is, html: true, container: '', scope: $ scope}); // modal opens the self Shodelog = function () {myDialog. $ Promise Then (function () {myDialog.show ();})}} // Expansion Update () method dialog template $ scope.Update = function {if (angular.isFunction (self.onUpdate)) {self.onUpdate ( ) (); }}}}}}) ();
Just use the 'admin' option:
< Code> $ Scope.showModal = function () {$ modal ({title: 'my title', content: 'my content', show: right, controller: 'ModalCtrl'}); };
No comments:
Post a Comment