javascript - How to clear an angular array -


 $scope.itemarray = ['a', 'b', 'c'];   

this clear array ui wont updated.

$scope.itemarray = []; 

this works fine! why?

 $scope.itemarray.length = 0;   

$scope.itemarray.length = 0; << correct. length read-write property.

$scope.itemarray = []; << creates new empty array. if have bindings old itemarray, may lost. (html binding ng-if="itemarray[0]" wont lost)


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -