Encountering the same ERROR
Argument 'AveragesCtrl' is not a function, got undefined
. Despite attempting various solutions found on SO, I am still unable to resolve this issue. Any insights into what might be causing my error?
<div >
<div ng-controller="AveragesCtrl">
<table>
<tr ng-repeat="actor in avengers.cast">
<td>{{actor.name}}</td>
<td>{{actor.character}}</td>
</tr>
</table>
</div>
</div>
JS
var myApp = angular.module("myApp", []);
myApp.factory('Averages', function () {
var Avengers = {};
Avengers.cast = [
{
name: "Robert Downey Jr.",
character: "Tony Stark / Iron Man"
},
{
name: "Chris Evans",
character: "Steve Rogers / Captain America"
},
{
name: "Mark Ruffalo",
character: "Bruce Banner / The Hulk"
},
...
// list of Avengers characters truncated for brevity
...
];
return Avengers;
});
myApp.controller("AvengersCtrl", function AvengersCtrl(Avengers) {
var avengersCtrl = this;
avengersCtrl.avengers = Avengers;
});