I've recently been learning Angular JS and have a reasonable grasp on the basics, I have looked at other 'How tos' and answers on here but I still can't wrap my head around Custom Directives and using $scope within them.
I'm hoping someone can explain to me where I've gone wrong and what I should be doing in laymans terms.
Thanks in advance:
I want <tablerow></tablerow> to display what's in the template for everything in $scope.tabledata.
Here is a link to the JSFiddle - https://jsfiddle.net/paulhume/tt29411t/14/
var myApp = angular.module('myApplication', []);
myApp.controller('myController', ['$scope', function($scope) {
$scope.tabledata = [
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' },
{ cellone: 'One', celltwo: 'Two', cellthree: 'Three' }
];
}]);
myApp.directive('tablerow', function() {
return {
restrict: 'E',
scope: { 'rows': '=tabledata' },
template: '<tr ng-repeat="row in rows"><td>Cell One</td><td>Cell Two</td></tr>'
}
});