How to use angular-ui-bootstrap (modals) in typescript?

前端 未结 2 1882
别跟我提以往
别跟我提以往 2021-02-08 11:03

I\'d like to edit some data from a table using a modal. There are various interfaces in the typescript definitions for angular-ui-bootstrap from definitelyTyped, however they ar

2条回答
  •  无人共我
    2021-02-08 11:15

    Am I right to assume that both ItemsListController and ItemDetailModalController need an instance of the same scope in order to exchange the data?

    Yes. I actually think of modals as an extension of ItemsListController containing members shownDetails:ItemDetailModalController. Which means you don't need to come up with a messy way of sharing $scope as its just a single $scope.

    And how can I define the controller and the template for the modal directive using the interfaces above?

    This is what I have (note that you are sharing the scope):

                this.$modal.open({
                    templateUrl: 'path/To/ItemModalDetails.html',
                    scope: this.$scope,
                })
    

    Where $modal:IModalService corresponds to what angular strap gives you : http://angular-ui.github.io/bootstrap/#/modal

提交回复
热议问题