Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

i recently bought an HTML template using AngularJS. This is a shop where you can add items on your cart, and i'd like to be able to make a function that empty the cart. When i run this command in console :

angular.element($0).scope()

I can get all my current variables. And i can see what is in the array cart : enter image description here

I created a basic JS function where it runs this :

$scope.cart = [];

This should empty the cart as this initialize the array as empty. I also tried others things found on stack but nothing works. But when i run the function, i refresh the page and my cart is still containing objects, while the angular.element($0).scope() command returns nothing. What am i forgetting ? Thank you in advance for your help :)

EDIT :

function myfct(){
    $scope.cart = [];
}
share|improve this question
    
I think we need to see more of your controller. – Amy 20 hours ago
    
Please provide a Minimal, Complete, and Verifiable example – charlietfl 20 hours ago
    
Ok sorry i don't really know angularJS i thought it was possible to just clear a variable with a delete or a simple line. What would you need ? – saperlipopette 20 hours ago
    
We need to see enough of your controller to reproduce the problem. You say you created a function where it clears the array. We don't know how that function is called, in what order, or under what circumstances. You may think you know the answers to those questions, but given that you're here asking for help, we can't rely on that. We need to see the code if you want help. – Amy 20 hours ago
    
Ok so i created a simple button EDIT : you'll find the code on the last edit of the topic – saperlipopette 20 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.