HTML and CSS Reference
In-Depth Information
The getController method accepts a string parameter representing the name of
the controller with its namespace. It will split the string into parts using the dot
character (fullstop) and then loop through the separate namespaces, gradually
building it up into an object.
app.bootstrap = (function(){
...
return {
/**
* Create an accessor for the controller,
* which accepts a string representation of the
* controller's namespace
*/
getController: function(name){
/**
* Split the string into an array using the .
* character to separate the string
*/
var parts = name.split('.');
/**
* Initially set the returned controller to null
*/
var returnController = null;
/**
* If the number of parts is greater than 0
*/
if(parts.length > 0){
/**
* Set the return controller to the parent object
*/
returnController = _controller;
/**
* Loop through each part, gradually assigning the
* action to the return controller
*/
for(var i = 0; i < parts.length; i++){
returnController = returnController[parts[i]];
}
}
/**
* Return the controller
*/
return returnController;
},
/**
 
Search WWH ::




Custom Search