I have a simple factory returning an array and a function:
function stockCommons() {
return {
unitTypes: [
{
code: 'UN',
unitTypeIndex: 0
},
{
code: 'PK',
unitTypeIndex: 2
},
],
unitTypeChanged: function (changedToUnitType) {
return var activeUnitType = stockCommons.unitTypes.filter(function (obj) {
return obj.code == changedToUnitType;
})[0];
}
}
In the function I'm trying to make a reference to the array at stockCommons.unitTypes
but it doesn't work. I've tried these solutions but they don't work either.
How can I use the unitTypes array in the function?