nonplus/angular-ui-router-uib-modal

Add support for "component"

Opened this issue · 6 comments

UI Router beta supports "component". It would be great to support it out of the box.

https://github.com/toddmotto/angular-component/blob/master/src/angular-component.js Todd Motto's polyfill may assist in some of this. I think you would just need to grab the component and use its controller and template/templateUrl and pass that into the options.

$stateProvider.state("productSearch.confirmSelectParentProductModal", { url: "/update", modal: true, params: { "selectedParentProduct": [] as IProduct[], "selectedProducts": [] as IProduct[] }, template: "<confirm-select-parent-product-modal></confirm-select-parent-product-modal>" } as ng.ui.IState);

this is what i'm doing now. perhaps a simpler solution would be to take the component name and set the template to its DOM tag.

for example, if options.component === "confirmSelectParentProductModal", then template === "".

so far this solution hasn't presented any problems for me.

I haven't used angular components. Can you point me to documentation on how they are used by ui-router in non-modal state definitions?

+1 - this would be awesome. Trying to use components everywhere I would normally have controllers and it's been working fantastic. For more info on component based architecture, check out Todd Motto's guide - https://github.com/toddmotto/angular-styleguide#components

I was having trouble, getting resolve to work with my modal component... adding the following resolve: '<' binding fixed the issue (by pulling in the resolves onto the vm).

    angular.module('app')
        .component('foobar', {
            template: require('./foobar.html'),
            controller: 'FoobarController as $ctrl',
            bindings: {
                resolve: '<'
            }
        })

https://stackoverflow.com/questions/39901439/how-to-use-resolve-with-angular-1-5-components-and-ui-bootstrap-modal