1
漂亮的基本東西...似乎它應該工作,但沒有Return Statement在Angualr沒有爲一個對象工作
這兩個控制檯日誌吐出正確的信息。
$scope.getCurrentAttachment = function() {
angular.forEach(attachments, function(attachment) {
console.log(attachment);
if(attachment.active) {
console.log(attachment);
return attachment;
}
});
};
但後來該文件調用它輪流不確定
$scope.save = function() {
console.log($scope.getCurrentAttachment());
var data = [$scope.labels.selected, $scope.getCurrentAttachment()];
console.log(data);
$uibModalInstance.close(data);
};
任何幫助將大大appriciated。我不知道爲什麼這不起作用
什麼是「附件」?它沒有被傳入$ scope.getCurrentAttachment作爲參數。範圍變量,全局變量,...? – jbrown
什麼應該工作?什麼是'undefined'? '$ scope.getCurrentAttachment'函數或'attachment'變量? [問]使用[mcve] – TheSharpieOne
返回的$ scope.getCurrentAttachment()未定義。 另外附件是一個填充的對象數組,將成功顯示在日誌中 –