Not fully understanding my scope issue here in angular and looking for clarity and how to fix this issue. I have an array of strings that I get from a service. What I'm trying to do is store those strings in one scope variable.
When my ui-select="loadDealStuff($item)"
is run I have a on-select method that passes the selected object in. If the key of that is a certain value then i'm removing some elements from my array. Other wise if its not then I need the original values from the array. Here is the code:
scope.productTypes = myService.constantsStrings.myProductTypes;
scope.otherTypes = myService.constantsStrings.myProductTypes;
var x = scope.productTypes;//array I want to manipulate
var y = scope.otherTypes;//should be original values
scope.loadDealStuff= function(item){
if(item.key == 3){
x.splice(0,1);
x.splice(2,1);
console.log(x);
} else {
console.log(y);
}
};
When logged y is the same as x.