简体   繁体   English

如何正确删除角度$ scope变量?

[英]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变量,该怎么做?

$scope.myVar = ";

This doesn't remove the variable. 这不会删除变量。 I want to completely remove it from the $scope. 我想将其从$ scope中完全删除。 What is the best way to do this performance wise? 明智地执行此性能的最佳方法是什么?

delete $scope.myVar;

请参阅delete运算符〜https ://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/delete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM