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
Post a Comment