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

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

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

java - Cannot secure connection using TLS -