Isaiah Grey
Isaiah Grey

Reputation: 93

How do I delete an angular $scope variable correctly?

I would like to delete a $scope variable in my controller, how can I do this?

$scope.myVar = ";

This doesn't remove the variable. I want to completely remove it from the $scope. What is the best way to do this performance wise?

Upvotes: 2

Views: 2246

Answers (1)

Phil
Phil

Reputation: 165059

delete $scope.myVar;

See the delete operator ~ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete

Upvotes: 4

Related Questions