Angularjs Restangular TypeError:无法将属性“route”设置为null
这是一个以前工作过的角函数Angularjs Restangular TypeError:无法将属性“route”设置为null,angularjs,restangular,Angularjs,Restangular,这是一个以前工作过的角函数 $scope.InsertLabelText = function () { var MapText = $("#txtMapLabel").val(); Restangular.setBaseUrl(BaseURL); if (MapText != null) { //Call WebAPI to enter text then refresh map. var TextObjs = Resta
$scope.InsertLabelText = function () {
var MapText = $("#txtMapLabel").val();
Restangular.setBaseUrl(BaseURL);
if (MapText != null) {
//Call WebAPI to enter text then refresh map.
var TextObjs = Restangular.all('PostObjects');
NewTextObject = {TypeMapId: "5", GrowerId: $("#GrowerName").val(), CropYear: $("#CropYear").val(), NAME: MapText, SHAPE: coordinates}
TextObjs.getList(NewTextObject).then(function (data) {
$scope.Label = data;
if ($scope.Label.Success = true) {
var geojson_format = new OpenLayers.Format.GeoJSON();
var Object_style = OpenLayers.Util.extend({}, layer_style);
Object_style.fillOpacity = 0.7;
Object_style.label = MapText;
Object_style.graphicZIndex = 4999;
Text.style = Object_style;
Text.addFeatures(geojson_format.read($scope.Label.TextObject));
LabelLine.destroyFeatures();
}
else {
console.log(data);
var Error = prompt($scope.Label.TextObject);
console.log("There was an error saving");
}
$("#divMapInputText").hide();
});
}
};
调用TextObjs.getList失败,错误为TypeError:无法将属性“route”设置为null
我在同一控制器中有3个其他函数,它们的代码模式相同,但它们都能工作吗
这是chrome的全部错误
TypeError: Cannot set property 'route' of null
at g (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/restangular.min.js:8:8705)
at t (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/restangular.min.js:8:11154)
at http://localhost/FarmMapsMvc4/Scripts/ThirdParty/restangular.min.js:8:13225
at http://localhost/FarmMapsMvc4/Scripts/ThirdParty/lodash.min.js:72:226
at y (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/lodash.min.js:16:110)
at Function.Et (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/lodash.min.js:72:191)
at http://localhost/FarmMapsMvc4/Scripts/ThirdParty/restangular.min.js:8:13149
at h (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/angular.min.js:78:33)
at http://localhost/FarmMapsMvc4/Scripts/ThirdParty/angular.min.js:78:266
at Object.e.$eval (http://localhost/FarmMapsMvc4/Scripts/ThirdParty/angular.min.js:88:347) angular.min.js:62(anonymous function) angular.min.js:62(anonymous function) angular.min.js:52h angular.min.js:78(anonymous function) angular.min.js:78e.$eval angular.min.js:88e.$digest angular.min.js:86e.$apply angular.min.js:88e angular.min.js:95p angular.min.js:98t.onreadystatechange
坐标变量在哪里启动?坐标被声明为控制器级别变量,并在用户单击时填充到另一个角度函数中。它应该工作。我看不出有什么不对劲。如果调试Restanglar的代码,您会发现问题在哪里?如果您添加一个responseInterceptor并在那里调试它,是否有从服务器返回的数据?请注意,该错误似乎表明无法将字段设置为可能来自服务器的未定义值