0

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.

2
  • make a directive with isolated scope and pass values as attribute. Commented Mar 11, 2016 at 6:04
  • Can you give me an example please? @AnandGargate Commented Mar 11, 2016 at 6:35

1 Answer 1

3

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'
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.