dependency injection

overview


dependency injection refers to the method that the davinci platform uses to call any of the component lifecycle methods. When a component exposes a lifecycle method, that method will be declared with a set of parameters. As an example, consider:

this.$html = function($id){
  return '<div id="'+$id(this.config.id)+'"></div></div>'					
}
The $html declared here takes an $id. That means that when the framework calls this method, it needs to pass the $id service to the function call. Likewise, the function could be declared as follows:

this.$html = function($page, $id){
  return '<div id="'+$id(this.config.id)+'"></div></div>'					
}
In this case, the function declaration indicates that it needs a $page and the $id services. The davinci framework will inspect what parameters are declared on the function before assembling the requested parameters and calling the function.

Note that the exact parameters passed will be dependent on the context. For instance, depending on where the component exists in the page (that is, if it is a child component of some other component) may dictate the implementation of the paraemeter that is passed to the function.

Component Services


There are a number of services that are provided by the framework that can be requested as a parameter to any lifecycle method. The current list is

  • $id
  • $page
  • $val
  • $config
  • $ctrl

Component Services - $id


In order to design a component, you must write your code to comply with the component specification. $id api.

Component Services - $val


In order to design a component, you must write your code to comply with the component specification. $val api.

Component Services - $page


In order to design a component, you must write your code to comply with the component specification. $page api.

Component Services - $ajax


In order to design a component, you must write your code to comply with the component specification. $ajax api.

Contents