我正在尝试通过单击按钮来切换div文本。我尝试使用范围变量并根据该变量切换类名。我哪里出错了heretesthellotestfunctionctrl($scope){$scope.state=vis;$scope.toggle=function(){state=!state;};}.vis{display:none;} 最佳答案 你可以像这样简化它testhellotestFiddleexample除非你需要特定的ng-class来切换,在这种情况下你可以做类似的事情testhellotestFiddleexample(只要确保你