0

I need some help with controller model data sharing.

In HTML I can access data by {{block.title}}, but also in html I have some javascript to open external file:

<div class="container">
    <accordion close-others="oneAtATime">
        <accordion-group ng-repeat="block in report.blocks" is-open="block.$$isOpen">
        <accordion-heading>{{block.tags}}
        </accordion-heading>
        <script>
        $(function() {
            $("#includedContent").load("res/filename.html");
        });
        </script>
        <div id="includedContent"></div>
       </accordion-group>
   </accordion>
</div>

What I want is to use current value of block.title (inside of ng-repeat) in place of filename.html like:

load("res/{{block.title}}.html").

How can I achieve that?

Thank you.

2
  • show your html.. It is quite simple.. you can do this using ng-model. Commented Feb 3, 2015 at 7:57
  • @Ved Updated in my question Commented Feb 3, 2015 at 8:28

1 Answer 1

2

You can achieve this in angular with relative ease, no jQuery needed.

<div id="includedContent" ng-include="getPartial(block.title)"></div>

In your controller

$scope.getPartial = function(file) {
    return "res/"+file;
};
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.