I have this directive:
App.directive('tablealerts', function(){
return {
restrict: 'E',
templateUrl: 'html/table_alerts.html',
controller: 'tableController',
replace: true,
scope: {
title: "@",
memberId: "=",
columns: "=",
accessor: "=",
export: "="
},
link : function(scope, element, attrs, controllers) {
console.log(scope);
console.log(element);
console.log(attrs);
console.log(controllers);
}
};
});
And this is the controller:
App.controller('tableController',['$scope','$rootScope',function($scope,$rootScope) {
console.log($scope.title);
}]);
Code is stripped for brevity, but if I now use the directive multiple times on an HTML like so:
<tablealerts title="Alerts"
columns="[{'label':'Date Time','value':'DateCreated'},
{'label':'Event','value':'EventName'},
{'label':'Device','value':'DeviceType'}]"
accessor="tableAccessor" member-id="1">
</tablealerts>
<tablealerts title="Events"
columns="[{'label':'Date Time','value':'DateCreated'},
{'label':'Device','value':'DeviceType'}]"
accessor="tableAccessor" member-id="2">
</tablealerts>
In the console I only see the title for one of the <tablealerts>
and not both.
Here is my console output:
Events
Scope {$id: 45, $$childTail: null, $$childHead: null,
$$prevSibling: null, $$nextSibling: null…}
[div.panel.panel-sky.ng-isolate-scope]
Attributes {$attr: Object, $$element: JQLite(1), title: "Events",
columns: "[{'label':'Date Time','value':'DateCreated'},
{'lab…ntName'},
{'label':'Device','value':'DeviceType'}]",
accessor: "tableAccidentAccessor"…}
Object {}
What am I doing wrong?