Skip to Content
0

models.createDeviceModel() is not a function

Feb 03 at 11:09 AM

63

avatar image

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");
notmethod.jpg (128.9 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Jun Wu Feb 04 at 05:14 AM
2
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
Share
10 |10000 characters needed characters left characters exceeded
Iftah Peretz
Feb 03 at 06:12 PM
0

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".

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

models.jpg (170.1 kB)
norenderer-ok.jpg (167.1 kB)
0
Jun Wu Feb 03 at 05:52 PM
0
test1/model/models  paste the code here
Show 3 Share
10 |10000 characters needed characters left characters exceeded

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;
		}


	};
});
0
Welly Sunarko
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

0

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

0
Emanuele Ricci Feb 05 at 10:47 AM
0

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

Not images, but the full code.

Thank you.

Share
10 |10000 characters needed characters left characters exceeded