Reputation: 667
I've been trying to improve myself on angularjs so i've started a project with angularjs in it. But i got stuck ...
I'm trying to ng-repeat some html elements using controller1.modalItems. Within the html template like below, i also want to dynamically add another template.
<div ng-repeat="li in modalItems">
<div ng-include="test.html"></div>
<div class="head">{{li.title}}</div>
</div>
here is the test.html
<script type="text/ng-template" src="test.html">
<ul >
<li ng-repeat="t in items">
<img src="{{ t.img }}" alt="" title="" />
</li>
</ul>
</script>
how can i pass the controller that it needs to repeated to test.html template.
Upvotes: 0
Views: 3692
Reputation: 569
Don't do that
https://docs.angularjs.org/api/ng/directive/ngController
A common mistake is to declare the controller again using ng-controller in the template itself. This will cause the controller to be attached and executed twice.
Upvotes: 0
Reputation: 34288
You can pass the controller using ng-controller
directive:
<div ng-include="test.html" ng-controller="theController"></div>
Upvotes: 2