I have two directives and am trying to filter a table based on a select box. I am using ui.bootstrap to create an accordion to hold the form. For some reason my form will not change the parent scope when clicked. I though "=" should change the parent scope but it doesn't seem to do anything IE: I would like to select DATE, Line Item, Creative, and then see only those fields in the table.
//table.js
var TableCtrl = function($scope,$rootScope){
$scope.headings = ['Date', 'Creative', 'Line item',
'Interactive impressions','Interaction time',
'Total interactions','Ad server clicks', 'Average interaction time'];
$scope.selectedHeadings = ['Date', 'Creative', 'Line item',
'Interactive impressions','Interaction time',
'Total interactions','Ad server clicks', 'Average interaction time'];
app.directive('campaignStatsTable',function(){
return {
$scope: true,
restrict: 'EA',
replace: 'true',
templateUrl: './views/templates/tables/table.html'
};
});
app.directive('tableFilter',function(){
return {
$scope: "=",
restrict: 'EA',
replace: 'true',
templateUrl: './views/templates/tables/table-filter.html'
};
});
app.controller('TableCtrl', ['$scope' ,'$rootScope', TableCtrl]);
My main html page
<accordion>
<accordion-group heading="Click to Edit Filtering Options">
<table-filter></table-filter>
</accordion-group>
</accordion>
My form template
<form id="table-filters" role="search">
<div class="form-group">
<select id='headerSelection' multiple ng-multiple=true ng-show='headings' ng-model="selectedHeadings" ng-options="heading for heading in headings"></select>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Line Item ID" ng-model="LineItemID">
</div>
</form>
My table template
<table class="table table-striped">
<th ng-repeat="header in selectedHeadings">
{{header}}
</th>
<tr ng-repeat="item in tableRecords | filter:Date | filter:line_item " item='item'>
<td ng-repeat="header in selectedHeadings" id='{{header}}' ng-href='#'>
<div ng-if="header == 'Date'">
{{item[header] | date:'EEE, MMM, dd'}}
<i class="btn fa fa-bar-chart" ng-click="refreshGraph(data,header, item[header])"></i>
</div>
<div ng-if="header != 'Date'">
{{item[header]}}
<i class='btn fa fa-bar-chart' tooltip='Click to sort the chart using this value' ng-if="['Creative', 'Line item'].indexOf(header) > -1" ng-click="refreshGraph(data,header, item[header])" ></i>
</div>
</td>
</tr>
</table>