I have an array called `arr` in a function that I want to return to `$scope.notifications` so that I can use it in the HTML within the Ionic Framework. I want to use a function to perform certain actions with the array before returning it later on. Here is my controller:
.controller('notificationsCtrl', function($scope) {
$scope.notifications = function(){
var arr = [
{user:"misterx", name:"Mister X", action:4, image: "https://www.holidaycheck.de/mediaproxy?target=hcaHR0cDovL3d3dy5ob3RlbC5kZS9tZWRpYS9ob3RlbC9waWN0dXJlcy8zMzQvMzM0MTIzL0V4dGVyaW9yXzYzNTkyNzk5NDMyODQ1OTAwMi5qcGc%3D"},
{user:"misterx", name:"Mister X", action:2, image: "https://www.holidaycheck.de/mediaproxy?target=hcaHR0cDovL3d3dy5ob3RlbC5kZS9tZWRpYS9ob3RlbC9waWN0dXJlcy8zMzQvMzM0MTIzL0V4dGVyaW9yXzYzNTkyNzk5NDMyODQ1OTAwMi5qcGc%3D"},
{user:"ladyx", name:"Lady X", action:1}
];
return arr;
}
})
The HTML:
<ion-item ng-repeat="msg in notifications" class="item-text-wrap">
<div class="row">
<div class="col-80">
<strong>{{msg.name}}</strong> (<em>@{{msg.user}}</em>) {{msg.action}}.
</div>
<div class="col-20">
<img src="{{msg.image}}" style="border-radius: 50px; width: 100%">
</div>
</div>
</ion-item>
When I directly pass notifications as an array without using a function, it works. What am I missing here?