Académique Documents
Professionnel Documents
Culture Documents
8dbd35e1577b445d8077b2bc6ad8b958
view on: demo kit nightly build | demo kit latest release
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel",
*HIGHLIGHT START* "sap/ui/Device"*HIGHLIGHT END*
], function (UIComponent, JSONModel, *HIGHLIGHT START*Device*HIGHLIGHT END*)
{
[…]
init: function () {
// set the device model
*HIGHLIGHT START* var oDeviceModel = new JSONModel(Device);
oDeviceModel.setDefaultBindingMode("OneWay");
this.setModel(oDeviceModel, "device");
*HIGHLIGHT END*
[…]
}
This instantiates a named JSONModel ("device") which contains all of the properties of the
sap.ui.Device class, like browser, device type, or the current orientation of the screen.
You can then bind the model properties in your views as follows:
Master.view.xml
If you want to negate a value of the device model or make a simple case decision, you can
use the expression binding syntax as shown below:
Master.view.xml
For more information, see sap.ui.Device in the API Reference in the Demo Kit, and the
documentation under The Device API.