如何在单击div后使用anguler js打开弹出窗口并将一些对象传递给窗口

时间:2015-05-17 10:25:37

标签: html angularjs angularjs-directive

我想知道如何用简单的动画在angulerjs中打开弹出窗口,背景应该是模糊或黑暗 以及如何将对象传递给新的弹出窗口

在html中 我有这种类型div

<div class="col-xs-7 col-md-2 rcorners2 " style="height:168px;width:126px;  margin-left: 10px" ng-click="clickevent(app)">

app.js我有这个

     app.controller('test',['$scope',function($scope){
    $scope.clickevent=function(app){
      $scope.app=app;
      alert(app.name);
    }
  }]);

此app对象内容不同属性app name description ... 那些属性shuld在按钮

的新弹出窗口中显示

我该怎么做

2 个答案:

答案 0 :(得分:0)

Wayne建议ngDialog这是一个选项,但我发现它真的很烦人...我只是使用bootstrap模态或ui.bootstrap $ modal ... ui.bootstrap只需使用$ modal ... < / p>

答案 1 :(得分:0)

  1. 你可以使用$ modal
    参考:https://angular-ui.github.io/bootstrap/
  2. SurveyID    Participant FavoriteColor   FavoriteFood    SurveyMonth ColorLevels FoodLevels  ParticipantLevels   MonthLevels
    S101        G92        Blue             Pizza           Jan                   1          1                  1             1
    S102        B34        Blue             Cake            Feb                   1          2                  2             2
    S103        Z28        Green            Cake            Feb                   2          2                  3             2
    S104        V11        Red              Cake            Feb                   3          2                  4             2
    S105        P03        Yellow           Pizza           Mar                   4          1                  5             3
    S106        A71        Red              Pizza           Mar                   3          1                  6             3
    S107        C48        Green            Cake            Mar                   2          2                  7             3
    S108        G92        Blue             Cake            Apr                   1          1                  1             4
    ...
    

    然后开始使用它。

    1. 使用javascript:
      将对象分配给窗口
    2. app.controller('yourController', yourController);
      yourController.$inject = ['$scope', '$modal'];
      function yourController($scope, $modal){...}
      

      然后在下一页检查window.opener

       const pageInfo = {
                   name: 'myPage',
                   url: 'http://myPage...'
               }
       window.pageInfo = pageInfo;
       window.open(pageInfo.url, "_blank");