如何将数据传递给 AngularJs HTML 模板

How to pass data to AngularJs HTML Template

我有一个 AngularJs HTML 模板,但该模板显示了 none 个 <td> 标签。我想知道如何将组件 JSON 对象传递给模板。

<div>
    <h4>Alert</h4>
    <table class="table">
        <tr>
            <th>Type</th>
            <td>{{component.type}}</td>
        </tr>
        <tr>
            <th>Alert</th>
            <td>{{component.alert}}</td>
        </tr>
    </table>
</div>

我希望将数据传递到此模板,但我在这样做时遇到了问题。

data: $scope.component 导致了问题。

$scope.components = 
    [
    {type: "Mobilizer",  alert:"mobilizer2 went down", status: "Down"},
    {type: "Dispacther", alert:"message rate is, status: "Problem"},
    {type: "Listener",   alert:"No Alert", status: "Up"},
    {type: "OutBound Charge", alert:"No Alert", status: "Up"}
];  

   $scope.openDialog = function(component) {
            ngDialog.open({
                templateUrl: 'handlebars/alert-template.html',
                data: $scope.component
            });
        };
    })

我的 AngularJs 调用函数的视图:

  <tr ng-repeat="component in components | orderBy:'status'" ng-click="openDialog(component)">
  <td>{{component.type}}</td>
  <td ng-if="component.status == 'Up'" class="alert-success">{{component.status}}</td>
  <td ng-if="component.status == 'Problem'" class="alert-warning">{{component.status}}</td>
  <td ng-if="component.status == 'Down'" class="alert-danger">{{component.status}}</td>
  </tr>
 $scope.component = component;
        ngDialog.open({
            template: 'handlebars/alert-template.html',
            scope: $scope

我必须在我的函数中分配范围。