The way you declare your array  is correct. What is not clear to me is what 
is the editExpense object ? Is there any other code you should show us ? 
Looking at the stacktrace where does it point you to ?



Le lundi 28 décembre 2015 08:51:58 UTC+1, ShatterStar a écrit :
>
> I have an array declared like so
>
> $scope.list = [ 
>  { date: "2015-01-01", detail: "Bought new wallet", amount: $filter(
> 'number')(150.00 , 2) },
>  { date: "2015-01-08", detail: "Bought shoes", amount: $filter('number')(
> 225.36 , 2) },
>  { date: "2015-01-12", detail: "Bought shirt", amount: $filter('number')(
> 300.89 , 2) },
>  { date: "2015-01-12", detail: "Paid electricity bill", amount: $filter(
> 'number')(190.9 , 2) },
>  { date: "2015-01-15", detail: "Paid phone account", amount: $filter(
> 'number')(115.00 , 2) }
>  ];
>
> I want to push new values into the array using the below function but the 
> list is not registering as a function
>
>  $scope.saveExpense = function(expenseItem){
>  if(angular.isDefined(expenseItem) && angular.isDefined(expenseItem.
> expenseDate) && angular.isDefined(expenseItem.detail) && angular.isDefined
> (expenseItem.amount))
>  {
>  expenseItem.amount = $filter('number')(expenseItem.amount, 2);
>  $scope.list.push({ date: $filter('date')($scope.myDate,'yyyy-MM-dd'), 
> detail: expenseItem.detail, amount: expenseItem.amount });
>  alert("Item added");
>  $route.reload();
>  }
>  }
>
> The error I get TypeError: $scope.list[editExpense.expenseID].push is not 
> a function, I thought declaring the list in the format [{ }] declared it as 
> an array, where am I going wrong?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to