2016-06-01 22 views
0

私はAngularJs HTMLテンプレートを持っていますが、テンプレートは表示されますが、<td>タグのどれも入力されません。私はどのように私のコンポーネントのJSONオブジェクトをテンプレートに渡すのだろうかと思います。AngularJs HTMLテンプレートにデータを渡す方法

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

あなたはすべてのHTMLを表示していないので、私は暗闇の中で刺すつもりです。 ng-controller属性を使用してコントローラを適切に関連付けましたか? – jbrown

答えて

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

私は関数内のスコープを割り当てる必要がありました。

関連する問題