Question: I want to add two associative arrays to the same array key or take out only from the array the keys I need like the example below, the keys I need in the fields array `$field = [a,b];`.

Lets say I have the blow array:

```
array1 = Array
(
    [key1] => Array
        (
            [a] => a
            [b] => b
            [c] => c
        )

    [key2] => Array
        (
            [a] => a
            [b] => b
            [c] => c
        )

)

$field = [a,b];
$x = [];

foreach ($array1 as $key) {
    foreach ($fields as $field) {
        $x[$key['id']] = array($field => $key[$field]);
      }
}
print_r($x);

```

output:

```
Array
(
    [key1] => Array
        (
            [b] => b
        )

    [key2] => Array
        (
            [b] => b
        )

)

```

I need:

```
Array
(
    [key1] => Array
        (
            [a] => a
            [b] => b
        )

    [key2] => Array
        (
            [a] => a
            [b] => b
        )

)

```

Answer: 
You need to inject the service to your controller and place the function inside the controller, you cannot call the service function directly from the template.

Or you could have your own filter to do the job,

```
.filter('mysce',function($http, $q, $log, $sce){  
     return $sce.trustAsHtml(text);
});

<span ng-bind-html = "review.positiveText | mysce"> </span>

```
If you want to make this common, instead of using service, you can use a `filter`

```
.filter('convertHtml',function($sce){
  return function(text){
     return $sce.trustAsHtml(text);
 }
})

<span ng-bind-html = "review.positiveText | convertHtml "> </span>

```