2017-11-05 11 views
0

In this plunkテーブルの要素の1つがディレクティブであるng-repeatテーブルがあります。問題は、ディレクティブフィールドがテーブルに表示されていないことです。このコードで何が問題になっていますか?ディレクティブ配列要素がテーブルに表示されない

HTML

<table border="1"> 
     <tr ng-repeat="row in rows"> 
     <td> 
      {{row.x}} 
     </td>    
     <td> 
      <div some-directive field="row.field"></div> 
     </td>    
     </tr> 
    </table> 

のJavascript

var app = angular.module('app', []); 

app.controller('myCtl', function($scope) { 

    $scope.rows = [{x: 1}, {x:2}]; 

}); 

app.directive('someDirective', function() { 

    var directive = {}; 

    directive.restrict = 'EA'; 

    directive.scope = {  
      field: '=' 
    }; 

    directive.link = function (scope, element, attrs) { 
     scope.field = "aaa"; 
    }; 

    return directive; 
}); 
+1

お客様の指令にはテンプレートがありません。なぜそれは何を表示するのだろうか? –

+0

ありがとう、テンプレートが問題だった – ps0604

答えて

0

答えは= "{{フィールド}}" directive.templateを追加することです。

関連する問題