I have an object like
Object {val1: "Hello", val2: "", dt1: "pilo1", dt2: "pilo2", lo1: "log1"}
Now i want to remove those keys that have empty values ("").
I tried the code:
angular.forEach($scope.test,function(value,key){
if(value==""){
var index = $scope.test.indexOf(key);
$scope.test.splice(index,1);
}
});
//$scope.test={val1: "Hello",val2: "",dt1:".......}
Now there is one more thing that i have to consider the keys are not static. They can change their name depends on the condition. For eg: {val1: "",val2:"Hello1",val3:"",val4:"Hello3",dt1:""}
So i need a generic solution.