I'm working on a legacy web application (well, I say legacy, it's from about a year ago and programmed in Knockout and JQuery), and I'd like to program a new interface in Angular, with a view to replacing all other portions of the application with Angular as we go on as this is a very complicated user interface that isn't horrible enough to warrant a complete rewrite.

I would like to integrate Angular code with the existing codebase, and for my first controller I'd like to program a pop-up box which allows the user to modify some data. I created a div with a `data-ng-controller` of "MyController" and it all works well, but I don't seem to be able to create many of them.

If we have multiple controllers, i.e:

```
<div data-ng-controller="MyController">
</div>
<div data-ng-controller="MyController">
</div>

```

Both instances of MyController would have their own scope which is definitely want, and it works totally fine for my app this way. But unfortunately, my system works on cloning a div for every instance of the pop-up box:

```
<div data-ng-controller="MyController" id="myWindow">
</div>

<script>
    function showWindow()
    {
        var dialog = $("myWindow").clone();
        dialog.show();
    )
</script>

```

When `showWIndow()` is called, the reference to MyController seems to travel along with it, so I don't get two instance of MyController.

I can't seem to find how to create multiple instances of the same controller and attach it though.

For example, I thought this might work:

```
<div id="myWindow">
</div>

<script>
    function showWindow()
    {
        var dialog = $("myWindow").clone().setupDialog();
        dialog.attr("data-ng-controller", "MyController");
        dialog.show();
    )
</script>

```

But unfortunately, the breakpoint in MyController never gets hit. I suspected that this might be due to the order of attaching, but reversing the call to attr() and show had no effect:

```
var dialog = $("myWindow").clone().setupDialog();
dialog.show();
dialog.attr("data-ng-controller", "MyController");

```

I assume that there's some method in the angular library somewhere that allows me to instantiate a controller and attach it to an element. About an hour of googling has yielded nothing but I can't believe that something like this doesn't exist somewhere.