Show TOC

Component.js FileLocate this document in the navigation structure

The Component.js file is the component controller and provides the runtime metadata and the component methods.

A component controller is defined with the asynchronous module definition (AMD) syntax. In the sap.ui.define statement; the required dependencies can be declared which can be used in the controller.

To create an SAPUI5 component, you extend either the Component or UIComponent base class and pass the name of the module (namespace + .Component).

sap.ui.define(['jquery.sap.global', 'sap/ui/core/UIComponent'],
	function(jQuery, UIComponent) {
	"use strict";

	var Component = UIComponent.extend("samples.components.sample.Component", {
		metadata : {
			manifest : "json"
		}
	});
	return Component;
});

The metadata of the component controller should be used to declare the runtime metadata only (which are the properties, aggregations, associations and events).

We recommend to define the component metadata externally in the descriptor (manifest.json), because the descriptor for components is mandatory for modern components and allows performance optimizations.