0

我试图打开模式窗口,从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}} 
+0

可以请你为你的问题创造plunker? – varit05

+0

https://plnkr.co/edit/WPPJwaFGGtLaab5Vk8KK类似的东西我认为 –

回答

0

解决办法:

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"); 
     }); 
    } 
相关问题