Skip to Content

Error loading model

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Apr 12, 2018 at 03:08 PM

    did you ever look at the error?

    globalVariables.js

    it has to be js file

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 12, 2018 at 03:15 PM

    but still it won't server your purpose

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 12, 2018 at 03:14 PM

    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

    Add comment
    10|10000 characters needed characters exceeded