I'm trying to use angular directive with table, but I don't see any data, when I use list I can see the data and it works properly. I'm using bootstrap for styling the table too. I really don't know what I'm doing wrong,
Hope you can help, here are the main parts of my code:
main.html:
<table class="table">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody ng-repeat="m in users">
<my-dir my-obj="m"></my-dir>
</tbody>
</table>
app.js:
var myApp = angular.module('myApp', ['ngRoute'])
myApp.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'pages/main.html',
controller: 'AppCtrl'
})
});
myApp.controller('AppCtrl', function($scope) {
$scope.users = [{name: 'john', age: 16}, {name: 'dani', age: 10}];
});
myApp.directive('myDir', function(){
return{
templateUrl: 'directive/mytbl.html',
replace: false,
scope:{
myObj: '='
}
}
})
mytbl.html:
<td>{{ myObj.name }}</td>
<td>{{ myObj.age }}</td>