-1

I have an AngularJS directive whose template file looks like this:

path/to/myDirectiveA.template.html:

<tr>
    <td bgcolor='#7cfc00'>Statement</td>
    <td bgcolor='#ff1493'>{{MyDirectiveACtrl.a.b}}</td>
</tr>

It works. The output looks like this:

enter image description here

But then I change the template file by adding an ng-repeat like this:

<tr ng-repeat="currRow in [0, 1, 2, 3]">
    <td bgcolor='#7cfc00'>Statement</td>
    <td bgcolor='#ff1493'>{{MyDirectiveACtrl.a.b}}</td>
    <td bgcolor='#7cfc00'>{{currRow}}</td>
</tr>

And that causes it to break as you can see in the image below. The phrase Hello World! is no longer showing up! Why? How can I fix this problem??

I simply don't see any logical reason why adding an ng-repeat should cause this breakage. It doesn't make sense to me at all.

enter image description here

If you need it, here is the controller and directive that invoke it can be found in this question I posted earlier.

Community
  • 1
  • 1
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272

2 Answers2

1
<tbody>
<tr ng-repeat="currRow in [0, 1, 2, 3]">
<td bgcolor='#7cfc00'>Statement</td>
<td bgcolor='#7cfc00'>MyDirectiveACtrl.a.b</td>
<td bgcolor='#ff1493'>{{MyDirectiveACtrl.a.b}}</td>
<td bgcolor='#7cfc00'>{{currRow}}</td>
</tr>
</tbody>

update your myDirectiveA.template.html .Hope it helps you :)

Ujjwal kaushik
  • 1,618
  • 11
  • 17
1

may this solve the problem ($parent)

<tr ng-repeat="currRow in [0, 1, 2, 3]">
    <td bgcolor='#7cfc00'>Statement</td>
    <td bgcolor='#ff1493'>{{$parent.a.b}}</td>
    <td bgcolor='#7cfc00'>{{currRow}}</td>
</tr>
Ahmad Abu Saa
  • 718
  • 6
  • 12