可以给你个简单示例:jsFiddle <div ng-controller="DemoCtrl"> <ng-table data="list"></ng-table> </div> var demo = angular.module('demo', []); demo.directive('ngTable', function(){ return { restrict: 'E', scope: { data: '=' }, link: function($scope, element, attrs){ }, template: '<table><tr ng-repeat="item in data"><td>{{ item.id }}</td><td>{{ item.name }}</td></tr></table>' }; }); demo.controller('DemoCtrl', function($scope){ $scope.list = [ { id: 123, name: 'Hello World' },{ id: 234, name: 'Fucking world' },{ id: 345, name: 'What did you say?' } ]; }); 至于是不是“只能传字符串”,你需要看明白文档先: 文档地址:scope
可以给你个简单示例:jsFiddle
至于是不是“只能传字符串”,你需要看明白文档先:
文档地址:scope