I'm trying to dynamically assign a controller for included template like so:
<section ng-repeat="panel in panels">
<div ng-include="'path/to/file.html'" ng-controller="{{panel}}"></div>
</section>
But Angular complains that {{panel}}
is undefined.
I'm guessing that {{panel}}
isn't defined yet (because I can echo out {{panel}}
inside the template).
I've seen plenty of examples of people setting ng-controller
equal to a variable like so: ng-controller="template.ctrlr"
. But, without creating a duplicate concurrant loop, I can't figure out how to have the value of {{panel}}
available when ng-controller
needs it.
P.S. I also tried setting ng-controller="{{panel}}"
in my template (thinking it must have resolved by then), but no dice.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…