Skip to content

Commit

Permalink
Added everything for Step 3: Create Property Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
wridgeu committed May 19, 2020
1 parent 24e6a13 commit 79ea293
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions webapp/controller/Home.controller.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
sap.ui.define([
"com/mrb/UI5-Data-Binding/controller/BaseController",
"sap/ui/model/json/JSONModel"
], function(BaseController, JSONModel) {
"use strict";
sap.ui.define(
[
"com/mrb/UI5-Data-Binding/controller/BaseController",
"sap/ui/model/json/JSONModel",
],
function (BaseController, JSONModel) {
"use strict";

return BaseController.extend("com.mrb.UI5-Data-Binding.controller.Home", {
onInit: function(){

var oModel = new JSONModel({
greetingText: "Hi, my name is Marco"
});
return BaseController.extend("com.mrb.UI5-Data-Binding.controller.Home", {
onInit: function () {
var oModel = new JSONModel({
greetingText: "Hi, my name is Marco",
});

//Set model globally for all Views/Controls (Dirty)
sap.ui.getCore().setModel(oModel);
}
});
});
//Set model globally for all views/controls (dirty) "sap.ui.getCore().setModel(oModel);""
//the go-to way for global definition would be to define the model within the manifest.json-file
//and retrieve it via "this.getOwnerComponent().getModel();"
this.getView().setModel(oModel);
},
});
}
);
2 changes: 1 addition & 1 deletion webapp/view/Home.view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:mvc="sap.ui.core.mvc">
<Page titleAlignment="Center" title="{i18n>title}">
<content>
<Text text="Hi, my name is Marco" ></Text>
<Text text="{/greetingText}" ></Text>
</content>
</Page>
</mvc:View>

0 comments on commit 79ea293

Please sign in to comment.