htmlangularjsng-dialog

How to pass data to AngularJs HTML Template


I have an AngularJs HTML template, the template displays however none of the <td> tags are populated. I am wondering how I pass my components JSON Object to the template.

<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>

I am looking to pass data to this template but I am having trouble in doing so.

data: $scope.component is causing the issue.

$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
            });
        };
    })

My AngularJs view which calls the function:

  <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>

Solution

  •  $scope.component = component;
            ngDialog.open({
                template: 'handlebars/alert-template.html',
                scope: $scope
    

    I had to assign the scope within my function.