我尝试使用 $scope.tiles = new UI();
$scope.tiles.loadUITiles();
console.log($scope.tiles);
$scope.rooms = new RoomData;
$scope.rooms.load();
buildSavedRoomsScope = (tiles,rooms) ->
console.log "tiles: " + tiles + " ||| Rooms:" + rooms
savedRooms = tiles.concat(rooms)
i = 0
while i < savedRooms.length
room = savedRooms[i]
room.saved = !room.hasOwnProperty('saved')
room.uid = (if room.saved then 'saved-' else 'notSaved-') + room.id
i++
room
$scope.savedRooms = buildSavedRoomsScope($scope.tiles, $scope.rooms)
console.log $scope.savedRooms
连接两个对象,但它返回
tiles.concat不是函数
这是代码(角度app和coffeescript):
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
我不明白我做错了什么,因为它看起来像我this
修改
就像在示例中一样,我的JSON数据是一个对象数组(与上面的例子结构相同)
答案 0 :(得分:3)
是的,没有&#39; concat&#39;对象的方法,它只存在于Array.prototype中。 相反,您可以使用angular.extend方法。请参阅doc:https://docs.angularjs.org/api/ng/function/angular.extend