0

I'm trying to use bindonce with an ng-repeat and it is causing the error:

Controller 'bindonce', required by directive 'ngRepeat', can't be found!

Here is the div causing the issue:

<div bo-if="transcripts.userIsAuthorizedForCourseTranscripts" bindonce ng-repeat="module in transcripts.modules">
...
</div>
Ryan Kohn
  • 13,079
  • 14
  • 56
  • 81
Jim Cooper
  • 5,113
  • 5
  • 30
  • 35
  • Just making sure, but I'm assuming you have included the module as a dependency? `angular.module('app', ['pasvaz.bindonce']);` A jsFiddle that repros the error would be nice... – Josh Jan 28 '14 at 01:36
  • Yes I have included it. I'll have to put together a fiddle to try to reproduce the problem. Thanks. – Jim Cooper Jan 28 '14 at 01:41

1 Answers1

1

when you have an ng-repeat it actually creates the element from the clone. This means that for everything in the repeat, the new element has both the bo-if and the bindonce. It seems like you want to only do the repeat if you have authority.

So if you want to only do the repeat if transcripts.userIsAuthorizedForCourseTranscripts === true then you would nest it like this:

// This assumes bindonce is declared above
<div bo-if="transcripts.userIsAuthorizedForCourseTranscripts">
    <div bindonce ng-repeat="i in stuff">
        #This area has bindonce using i
    </div>
</div>

I also made a fiddle showing this case http://jsfiddle.net/49c5C/1/

Hope this helped!

hassassin
  • 5,024
  • 1
  • 29
  • 38