SAPUI5 get current context in detail view
You can use getPath()
of a bindingContext to see what object is currently displayed:
this.getView().getBindingContext().getPath();
You could do something like this:
var bindingContext = this.getView().getBindingContext();
var path = bindingContext.getPath();
var object = bindingContext.getModel().getProperty(path);
If you only want a certain property of your displayed object you can do something like this:
var property = bindingContext.getProperty("<nameOfProperty>");
which returns a property of an object at specific context.
Update:
You can simply call getObject()
of a bindingContext which returns the object in the model the current context points to:
var object = bindingContext.getObject();
See the documentation of Context for more information.