Skip to Content
0

Error loading model

Apr 12 at 02:58 PM

22

avatar image

Hi i'm triying to use a model as global variables but i'm having troubles to load my model on the controller:

this is my controller:

sap.ui.define([
	"jquery.sap.global",
	"sap/ui/core/mvc/Controller",
	"sap/m/MessageToast",
	"sap/ui/model/Filter",
    "sap/ui/model/odata/ODataModel",
    "sap/ui/model/json/JSONModel",
    "one/screen/model/globalVariables"
], function (jQuery, Controller, MessageToast, Filter, ODataModel, JSONModel) {
	
	"use strict";
	return Controller.extend("one.screen.controller.Main", {
		globalVariables : globalVariables,
		oFecha: "", // Variable global de la fecha
		nFecha: "",
		oModel: oModel = new sap.ui.model.json.JSONModel(globalVariables),

but i'm getting this error:

and i can see it in the tab sources:

this is my project structure

this is my namespace in my index:

data-sap-ui-resourceroots='{"one.screen": "./"}'

any idea?

model.png (50.6 kB)
soruces.png (6.9 kB)
structure.png (11.0 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Jun Wu Apr 12 at 03:08 PM
0

did you ever look at the error?

globalVariables.js

it has to be js file

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Apr 12 at 03:15 PM
0

but still it won't server your purpose

Share
10 |10000 characters needed characters left characters exceeded
Ivan Mirisola
Apr 12 at 03:14 PM
0

Hi Naoto,

The clause "sap.ui.define" expects javascript code, not json files. Notice that it replaced the file extension with ".js" instead of json.

Try creating a function that returns a json on this JS and then call it on your model instance.

Regards,
Ivan

Share
10 |10000 characters needed characters left characters exceeded