API to enable Hooks for Hi-Framework
- beforeRun hook now receives one argument : the hi-framework angular module object - hook must be used to set configuration on the hi app module object.
- new hook: setupApp - hook to set configurations on the app module object
<dependencies>
<dependency>
<groupId>org.emerjoin</groupId>
<artifactId>Hi-Framework-Hooks</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<script src="webroot/emerjoin/hf-hooks.min.js"></script>
This hook is executed before the angular application is run. You can add as many hooks as you need.
AppHooks.beforeRun(function(hiAppModule){
hiAppModule.config(function(){
//do something here
});
hiAppModule.run(function(){
//Do more here
});
});
This hook is executed before a specific view controller gets executed. This hook allows to transform the view's $scope object and to add objects to be resolved upon dependencies injection.
Allows to transform the view's $scope object.
AppHooks.beforeView(function(before){
//The $scope object is bound to "this" keyword
before.transform(function(){
//This property is being added to the view's $scope
this.car = {brand:"Toyota",model:"Rav4"};
},"controler/action");
});
Hi.view(function($scope){
console.log($scope.car.brand); //Toyota
});
Allows to add objects to be resolved during dependency injection
AppHooks.beforeView(function(before){
//This function is meant to add objects to be resolved during dependency injection
before.inject(function(){
this.person = {name:"Mario",surname:"Junior"};
});
},"controler/action");
Hi.view(function($scope,person){
console.log(person.name);//Mario
});
Invoke the AppHooks.beforeView function without passing the second parameter (view url).
AppHooks.beforeView(function(before){
//Do something in here
});
Hook used to set configuration on the app module object
AppHooks.setupApp(function(appModule){
appModule.config(function(){
//do something here
});
appModule.run(function(){
//Do more here
});
});