Question: I have to make a web page with two different window and let they share some variables.

When the main window is loaded, the second windows is opened, and here I can store the second window object and access its vars:

**Main window**

```
var mainvar=1;
var secondwindow=open('second.htm');
$("button").click(function(){
    alert(secondwindow.testvar);
});

```

My trouble starts when I want to do the oppsite: access main window vars from the second window script:

**Second window**

```
var secondvar=2;
var mainwindow;// how can I set this?
$("bunno").click(function(){
   alert(mainwindow.testvar);
});

```

Answer: 
You should create custom filter function:

```
$scope.myFilter = function (x) {
  return function (y) {
    if (x.n==y.n) {
      return true;
    } else {
      return false;
    }
  }
};

```

Use it in inner ng-repeat:

```
 <div ng-repeat="y in amt | orderBy:'v' | filter:myFilter(x) | limitTo:1">
   <div>{{y.v}}</div>
 </div >

```

Also, to get top 1 result add standard limitTo filter (limitTo:1), wich first argument sets max return count.
`(...)
 < /tr>
 < /thead>
 < tbody>
 < tr ng-repeat="object in objects | SOME_FILTER">
 (...)
 {{object.get("element")}}
 {{(object.get("element2")).innerElement}}
 (...)
 < /tr>
 < /tbody>
 < /table>
 (...)`

The 3 dots means that there was some code cut out. "element2" is the one with a JSON inside. "innerElement" is the key. it worked for me, hope would be useful to someone