0
У меня есть HTML-шаблон AngularJs, однако шаблон отображается, но ни один из тегов <td>
не заполняется. Мне интересно, как передать свой компонент JSON Object в шаблон.Как передать данные в HTML-шаблон AngularJs
<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>
Вы не показываете весь свой html, поэтому я собираюсь сделать удар в темноте. Правильно ли вы связали контроллер с помощью атрибута ng-controller? – jbrown