craftpip / angular-confirm

A multipurpose plugin for alert, confirm & dialog for angular1
http://craftpip.github.io/angular-confirm/
MIT License
115 stars 20 forks source link

ControllerAs synax #9

Open ChaudhryAtif opened 7 years ago

ChaudhryAtif commented 7 years ago

Don't think I saw an option for this in the document, but 'ControllerAs' syntax would be nice to have. This would allow the ability to pass 'this' as scope. Not sure if the following will be helpful:

// controller declaration
var vm = this;
$ngConfirm({
    scope: vm
});
craftpip commented 7 years ago

Can you please explain if angular-confirm had an option for controllerAs, how would it look like ?

The example you provided is valid though, angular-confirm requires a scope, which is vm in this case, will work fine.

ChaudhryAtif commented 7 years ago

Will something like this work as well:

$ngConfirm({
    controller: ['$filter', function($filter) {
        var vm = this;
        // Controller code here
    }],
    controllerAs: 'vm'
});
craftpip commented 7 years ago

Do you know any other plugin that does this?

Currently angular-confirm simply takes the template and compiles it with the scope, and returns the scope. adding the proposed thing will be complicated.

ChaudhryAtif commented 7 years ago

ngDialog is one plugin that does it