这是以前有效的Angular函数......
$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