1

除了使用 ngDialog 库之外,我还使用 ng-repeat 从 Firebase 填充用户对象。我的目标是,当您单击“查看”按钮时,会弹出一个小对话框,您可以在其中查看用户的详细信息。但是,我正在尝试遵循 ngDialog 的文档,并且我的弹出模板没有呈现任何表达式。

数据模型:

{
"members": {
"-JWT5y43YFy1mGirVVS2": {
  "date": 1410328158691,
  "firstname": "Michael",
  "image": "http://telehealth.org/wp-content/images/user-placeholder.jpg",
  "upcoming": "PTO on Thursday",
  "status": {
    "color":  "red",
    "contact": {
      "email": "test@email.com",
      "yahoo": "yahooIM"
    },
    "projects": {
      "projectone": "project one",
      "projecttwo": "project two",
      "projectthree": "project three",
      "projectfour": "project four",
      "projectfive": "project five",
      "projectsix": "project six",
      "projectseven": "project seven",
      "projecteight": "project eight",
      "projectnine": "project nine",
      "projectten": "project ten"
    }
  }
},
"-JWT65QvjwD4TSFjDx4V": {
  "date": 1410328192928,
  "firstname": "Magic",
  "image": "http://telehealth.org/wp-content/images/user-placeholder.jpg",
  "upcoming": "PTO on Thursday",
  "status": {
    "color":  "yellow",
    "contact": {
      "email": "test@email.com",
      "yahoo": "yahooIM"
    },
    "projects": {
      "projectone": "project one",
      "projecttwo": "project two",
      "projectthree": "project three",
      "projectfour": "project four",
      "projectfive": "project five",
      "projectsix": "project six",
      "projectseven": "project seven",
      "projecteight": "project eight",
      "projectnine": "project nine",
      "projectten": "project ten"
    }
  }
}

HTML:

<ul class="cbp-rfgrid" ng-repeat="member in members">
  <li class="{{member.status.color}}">
    <div class="dripicon profilephoto">&#xe084;</div>
    <div>
        <h3>{{member.firstname}}</h3>
        <div class="dripicon actions" 
            ng-click="viewStatus()">&#xe077;</div>

        <div class="dripicon actions" 
            ng-click="editStatus()">&#xe036;</div>
    </div>
  </li>
</ul>

控制器:

myApp.controller('MembersController', function($scope, $firebase, $location, ngDialog){

var ref = new Firebase('https://scrumcheck.firebaseio.com/members');
var members = $firebase(ref);

$scope.members = members.$asObject();

  $scope.viewStatus = function(){
    ngDialog.open({ template: 'views/popupTmpl.html' });
  }

  $scope.editStatus = function(){
    //not entered yet
  }

});

popupTmpl.html

<p>External modal template with external scope: <code>{{member.firstname}}</code></p>

当我点击“查看”按钮,触发 viewStatus() 函数时,我没有得到任何关于 {{member.firstname}} 的信息 - 有人根据您看到的内容有任何建议吗?

再次感谢!

4

1 回答 1

0

在 popupTmpl.html 中,你必须写 ng-repeat = "member in members" 然后写 {{memeber.firstname}}

于 2015-03-02T05:29:50.713 回答