Skip to Content
-1
Jul 01, 2020 at 11:30 PM

SAP UI5 Problem with Closure

264 Views

Hi,

I have the following code inside a controller that is reading a record using oData model. In success function I am trying to access the outer function variable "that". But I get the error "Uncaught ReferenceError: that is not defined". I am not able to identify the issue. Can you please advise what I am missing? Thanks for the help

Regards, Ravikanth

		onRouteMatched: function () {
			debugger;
			var oModel = this.getOwnerComponent().getModel("PES");
			var path = "/DEFAULTSSet('ABCD')";
			var that = this;
			oModel.read(path, {
				async: false,
				success: function (oData) {
					that.getOwnerComponent().getModel("defaults");
				},
				error: function (oError) {
				}
			});
		},