I have the following AngularJS template file:
<div ng-controller="PredictionCtrl as predictionCtrl">
<table width="40%" border="1">
<tbody>
<tr>
<td bgcolor="orange">A</td>
<td bgcolor="yellow">B</td>
</tr>
</tbody>
<tfoot>
<tr>
<td bgcolor="pink">C</td>
<td bgcolor="cyan">D</td>
</tr>
</tfoot>
</table>
<br>
<table width="40%" border="1">
<tbody>
<rpt-my-directive-a p="1" q="2"></rpt-my-directive-a>
</tbody>
<tfoot>
<rpt-my-directive-b r="3" s="4"></rpt-my-directive-a>
</tfoot>
</table>
</div>
In the template for my directive myDirectiveA
, I have the following:
<tr>
<td bgcolor="orange">E</td>
<td bgcolor="yellow">F</td>
</tr>
In the template for my directive myDirectiveB
, I have the following:
<tr>
<td bgcolor="pink">G</td>
<td bgcolor="cyan">H</td>
</tr>
The output looks like this:
I was expecting two identical-looking tables. Instead I got one with the proper colors and one without. Why did the table that was constructed using AngularJS directives come out looking different than the plain-HTML one?? How do I fix this? I want the second table to look just like the first.
EDIT #1:
When I took Sergey's advice below, the declaration for myDirectiveA
now looks like this:
myApp.directive('myDirectiveA',function(){
return {
restrict:'A',
replace: true,
scope: {
p: '=',
q: '='
},
controller: 'MyDirectiveACtrl',
controllerAs: 'MyDirectiveACtrl',
bindToController: true,
template: '<div ng-include="MyDirectiveACtrl.myDirectiveAHTML"></div>'
};
}
);
and the output now looks like this: