cancel
Showing results for 
Search instead for 
Did you mean: 

models.createDeviceModel() is not a function

wsunarko
Participant
0 Kudos

Got "models.createDeviceModel() is not a function" error from the following script in Component.js

What could be the reason ?

Thank you.

sap.ui.define([
	"sap/ui/core/UIComponent",
	"sap/ui/Device",
	"sap/ushell/renderers/fiori2/Renderer",
	"test1/model/models"
], function(UIComponent, Device, models) {
	"use strict";


	return UIComponent.extend("test1.Component", {


		metadata: {
			manifest: "json"
		},
		

		/**
		 * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
		 * @public
		 * @override
		 */
		init: function() {
			// call the base component's init function
			UIComponent.prototype.init.apply(this, arguments);


			// set the device model
			this.setModel(models.createDeviceModel(), "device");

Accepted Solutions (1)

Accepted Solutions (1)

junwu
Active Contributor
sap.ui.define(["sap/ui/core/UIComponent","sap/ui/Device","sap/ushell/renderers/fiori2/Renderer","test1/model/models"],function(UIComponent, Device, Renderer, models){
Renderer   you missed this one in function parameter

Answers (3)

Answers (3)

ericci
Active Contributor
0 Kudos

Could you please attach both Component.js and models.js code?

Not images, but the full code.

Thank you.

iftah_peretz
Active Contributor
0 Kudos

Hi,

Based on the screenshot you provided this is not the same code.

How is the code you are asking about is doing? In it, are you getting the same error? If so, please provide a screenshot of it and the content of the variable "models".

wsunarko
Participant
0 Kudos

Hi Iftah, Thanks for your reply.

I am getting the same error. If I get rid of "sap/ushell/renderers/fiori2/Renderer" from sap.ui.define, then it passes this line.

this.setModel(models.createDeviceModel(), "device");

But of course I get the renderer error.

junwu
Active Contributor
0 Kudos
test1/model/models  paste the code here
wsunarko
Participant
0 Kudos

Thanks for your reply Jun,

I found that if I delete "sap/ushell/renderers/fiori2/Renderer" from sap.ui.define, the error is gone, but I need the Renderer.

here is the script for models

//test1/model/models

sap.ui.define([
	"sap/ui/model/json/JSONModel",
	"sap/ui/Device"
], function(JSONModel, Device) {
	"use strict";


	return {


		createDeviceModel: function() {
			var oModel = new JSONModel(Device);
			oModel.setDefaultBindingMode("OneWay");
			return oModel;
		}


	};
});
junwu
Active Contributor
0 Kudos
sap.ui.define(["sap/ui/core/UIComponent","sap/ui/Device","sap/ushell/renderers/fiori2/Renderer","test1/model/models"],function(UIComponent, Device, Renderer, models){

you missed one in define

wsunarko
Participant
0 Kudos

Sorry, which one is missing ? please clarify. Thank you