【问题标题】:How to send data to UI Bootstrap Modal window $scope?如何将数据发送到 UI Bootstrap 模态窗口 $scope?
【发布时间】:2016-07-08 09:34:14
【问题描述】:

我正在尝试打开模式窗口,从那里的 SQL 查询发送数据并更改表单的值,但它不起作用。我想我应该以某种方式将它发送到模态范围,但我不知道该怎么做。

js 文件:

addUser() {
    return this.Server.getUsers()
        .then((res) => {
            this.users = res.users;
            this.$modal.open({
                templateUrl: 'user.html'
            });
        });

还有玉文件:

script(type="text/ng-template", id="users.html")
    div.page-header: h1 !{__('Users')}
    div.panel.panel-default
        div.panel-heading
            h3.panel-title !{__('Users')}
        table.table.table-hover.table-condensed
            thead
                tr
                    th.col-lg-2 !{__('Name')}
                    th.col-lg-5 !{__('Description')}
            tbody
                tr(ng-repeat="u in users.users")
                    td {{u.name}}
                    td {{u.description}}

【问题讨论】:

标签: javascript angularjs twitter-bootstrap pug angular-ui-bootstrap


【解决方案1】:

解决办法:

   addUser() {
        return this.$modal.open({
            templateUrl: 'user.html',
            controller: ['$scope', 'Server', function ($scope, Server) {

                $scope.users = Server.getUsers()
                    .then((res) => {
                        this.users = res.users;
                    });
            }],
            controllerAs: "add_user"
        }).result.then((res) => {
            return console.log("Saved");
        });
    }

【讨论】:

    猜你喜欢
    • 2014-01-02
    • 1970-01-01
    • 1970-01-01
    • 2013-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-11
    • 1970-01-01
    相关资源
    最近更新 更多