我有這樣的功能:條件語句來檢查,如果數組是空的,角JS
$scope.doPaste = function(destination) {
if ($scope.selectCopy.ids != []) {
console.log("will copy");
$scope.CopyFiles(destination);
}
if ($scope.selectMove.ids != []) {
console.log("will move");
$scope.MoveFiles(destination);
}
};
在我的應用程序,$scope.selectMove.ids
和$scope.selectCopy.ids
不能同時非空。我的意思是,例如當$scope.selectMove.ids
非空時$scope.selectCopy.ids
爲空。
我的問題是,在控制檯中,我總是看到兩者都會複製並移動。
你最好檢查'.length'屬性! –