cancel
Showing results for 
Search instead for 
Did you mean: 

How to change title of the page using Ui5

0 Kudos
698

Hi,

I want to change my page title, the value will be coming from Odata service.

I am trying with, title = "{ProjectData>Project_Name}",

but unable to get any data, header shows nothing.

It would be great help, if anyone suggest me with some other options, I am pretty new in Ui5.

Thanks In Advance.

View Entire Topic
iftah_peretz
Active Contributor
0 Kudos

Hi,

Here is an option how to do it (inside the views' controller)

onInit: function() {
	var oModel = new JSONModel(...the place you get the OData from...);
	this.getView().setModel(oModel);
	oModel.attachRequestCompleted(function(oEvent) {
	        var oActiveModel = oEvent.getSource();
		document.title = oActiveModel.getProperty('/ProjectData/0/Project_Name');
			});
		    },

I am assuming the following JSON structure

"ProjectData":[{"Project_Name":"Title from OData"}]