Monday, July 30, 2018

Spring Boot Example of Exposing REST Service


Step1:- Downlaod STS as IDE
Step 2:- Create Spring Boot Project
rigth click -> New -- > Others -->Spring Starter Project








This will create below given project structure for you



Step 3:- Create Bean file with getter and setter method



Step 4:- Create Controller class



Step 5:- As we are using Maven we need to use following pom.xml




Step 6:- Run the project using maven build and once the jar files created execute the below command

C:\workspace-sts-3.9.4.RELEASE\spring-boot-rest\target>java -jar spring-boot-rest-0.0.1-SNAPSHOT.jar

and see hit the browser with this url

http://localhost:8083/siddhu/message?name=siddhudhumale





Sunday, July 15, 2018

How can I listen for keypress event on the whole page in AngularJS 2 – 6

Add following line on @component decorator class
host: {‘(document:keypress)’: ‘handleKeyboardEvent($event)’}
and implement handleKeyboardEvent(event:KeyboardEvent)
i.e.
@Component({
selector:’app-add-component’,
templateUrl:’./add-component.component.html’,
styleUrls: [‘./add-component.component.css’],
// tslint:disable-next-line:use-host-property-decorator
host: {‘(document:keypress)’:’handleKeyboardEvent($event)’}
})
handleKeyboardEvent(event: KeyboardEvent) {
console.log(event);
if (event.keyCode===13)
{
console.log(“Enter key pressed 13”);
} else if (event.keyCode === 40)
{
} else if (event.keyCode === 38)
{
}
}

How to disable browser back button in AngularJS 2 to 6

Use location.onPopState to the same in AppComponent
import { PlatformLocation } from ‘@angular/common’;
constructor(location: PlatformLocation, private router: Router) {
location.onPopState(() => {
console.log(‘pressed back in add!!!!!’);
//this.router.navigateByUrl(‘/multicomponent’);
//history.forward();
});