on 02-03-2018 11:09 AM
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");
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please attach both Component.js and models.js code?
Not images, but the full code.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
test1/model/models paste the code here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
}
};
});
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.