Why does calling a method in my controller result in the object.name being logged multiple times?
(function(){
var app = angular.module('portfolio', ['ngRoute' ]);
app.controller('ReferenceController', function(){
this.product = references;
this.arrayLength = this.product.length;
// @TODO
this.getReferences = function(){
for(var i = 0; i < this.arrayLength; i++){
console.log(this.product[i].name);
}
return false;
};
});
var references = [
{
name: "ThisIsName",
imgUrl: "This Is Image URL",
pageUrl: "This Is Page URL",
tags: [
{tag: "web"}
]
}
];
})();
The method is called as shown below
<div ng-controller='ReferenceController as reference'>
{{reference.getReferences()}}
</div>