Skip to Content

models.createDeviceModel() is not a function

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

  • Get RSS Feed

4 Answers

  • Best Answer
    Feb 04 at 05:14 AM
    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
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 03 at 06:12 PM

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

    Add comment
    10|10000 characters needed 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)
  • Feb 03 at 05:52 PM
    test1/model/models  paste the code here
    Add comment
    10|10000 characters needed characters exceeded

  • Feb 05 at 10:47 AM

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

    Not images, but the full code.

    Thank you.

    Add comment
    10|10000 characters needed characters exceeded