AngularJS 버전 1.5.11을 사용하고 있습니다.AngularJS ng-options 오류 : 복사 할 수 없습니다! Window 또는 Scope 인스턴스를 복사 할 수 없습니다.
I가 NG-옵션을 사용하여 선택 (복수) 소자를 만들었다 :
<select multiple class="form-control" ng-model="vm.selectedBuildings" ng-options="building as building.name for building in vm.buildings track by building.id"></select>
I 대신 selectedBuildings 배열 밀려 요소의 상기 요소 중 하나를 선택할 때마다, I는 오류를 " 복사 할 수 없습니다! Window 또는 Scope 인스턴스의 복사본을 만들 수 없습니다. "
나는 이것을 알아 내려고 수많은 시간을 보냈습니다. 누군가 제발 도와주세요!
제어기var self = this;
self.selectedBuildings = [];
function getBuildings() {
buildingService.getBuildings(campusId, function (buildings) {
// retrieve buildings from API
self.buildings = buildings;
// etc, etc
});
}
// I am using a Bootstrap modal to display some information.
// I have multiple structures but only one modal, so when the
// modal is shown, I dynamically populate self.selectedBuildings.
$("#modal-lot").on("shown.bs.modal", function() {
// etc, etc
var lot = self.lots[self.structureToUpdate];
for (var i = 0; i < self.buildings.length; i++) {
let building = self.buildings[i];
let index = lot.buildings.indexOf(building.id);
if (index > -1) {
self.selectedBuildings.push(building);
}
}
// etc, etc
$scope.$apply();
});
// When the modal is hidden, clear the array
$("#modal-lot").on("hidden.bs.modal", function() {
self.selectedBuildings = [];
});
오류 메시지에서
관련 코드
Error: [ng:cpws] Can't copy! Making copies of Window or Scope instances is not supported.
http://errors.angularjs.org/1.5.11/ng/cpws
http://***/static/bower_components/angular/angular.js:68:32
[email protected]://***/static/bower_components/angular/angular.js:961:21
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:922:37
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:933:41
[email protected]://***/static/bower_components/angular/angular.js:922:37
[email protected]://***/static/bower_components/angular/angular.js:933:41
http://***/static/bower_components/angular/angular.js:29665:91
[email protected]://***/static/bower_components/angular/angular.js:325:24
[email protected]://***/static/bower_components/angular/angular.js:29663:18
http://***/static/bower_components/angular/angular.js:31995:57
[email protected]://***/static/bower_components/angular/angular.js:18094:30
http://***/static/bower_components/angular/angular.js:31994:21
[email protected]://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js:3:10320
컨트롤러에서 코드를 더 보내십시오. –
이 오류의 원인이 될 수있는 코드에는 아무 것도없는 것 같습니다. – JLRishe
방금 더 많은 코드를 추가했습니다. 이 모든 도움이됩니까? – iXterminate