angular-confirm icon indicating copy to clipboard operation
angular-confirm copied to clipboard

ControllerAs synax

Open ChaudhryAtif opened this issue 8 years ago • 4 comments

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

ChaudhryAtif avatar Mar 20 '17 23:03 ChaudhryAtif

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.

craftpip avatar Mar 21 '17 11:03 craftpip

Will something like this work as well:

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

ChaudhryAtif avatar Mar 21 '17 12:03 ChaudhryAtif

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.

craftpip avatar Mar 22 '17 17:03 craftpip

ngDialog is one plugin that does it

ChaudhryAtif avatar Mar 22 '17 19:03 ChaudhryAtif