向angular指令传参

来源:互联网 发布:mac解压缩软件 编辑:程序博客网 时间:2024/06/06 09:14
https://segmentfault.com/q/1010000005837178

<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?'
}
];
});
0 0
原创粉丝点击