Reputation: 1253
After searching and trying lots of things, I can't seem to find a solution to pass a scope object into a include file.
I have tried
<span ng-init="list_title = clients_list.title;
list_subtitle = clients_list.subtitle;
list_array = clients_list.clients"
ng-include="'/views/partials/lists/list_with_qty.html'">
</span>
and
<span onload="list_title = publishers_list.title;
list_subtitle = publishers_list.subtitle;
list_array = publishers_list.clients"
ng-include="'/views/partials/lists/list_with_qty.html'">
</span>
and
<span ng-include-variables="list_title = publishers_list.title;
list_subtitle = publishers_list.subtitle;
list_array = publishers_list.clients"
ng-include="'/views/partials/lists/list_with_qty.html'">
</span>
they both pass through the object when called on the page by themselves. However I am trying to include both of these includes one after another.
How can I pass through the variables so that the result isn't the same.
Thanks in advance.
Upvotes: 0
Views: 74
Reputation: 489
Please refer this plunkr http://plnkr.co/edit/M9cIxNfRIWA8gB41rx1Q?p=preview I have made directive with isolated scope. Replace your template with given list.html
angular.module('app', []).directive('listWithQty', function() {
return{
scope: {
listTitle: '=',
listSubtitle: '=',
listArray: '='
},
templateUrl: 'list.html'
}
Upvotes: 3