Posts

Showing posts from April, 2016

JavaScript Notes

Coming from the Java background, my main problem with JavaScript is encapsulation: global space is not good. I love OO because object is the best place to encapsulate the data. Here are the patterns I would like to follow always. In the JavaScript, function can be used as : function method constructors classes Module As a first example, will start with the Module. Module Pattern In this pattern, you can define number of privilege method which have access to the secret information such as private variables and methods . For example, setFirstName method can set the name local variable as well as the function getUserFullName has access to the private method getFullName as shown int he following code: var person = ( function (firstName, lastName, age) { //properties var a = age; var fname = firstName; var lname = lastName; //common functions function getFullName (f,l) { return fname+ " " +lname; } return { //open to outside ...

Spring 3 Part 10: Java Web development with AngularJS

Angular Basics AngularJS is MVC based fronted framework. To make the things easier, I’ve use Atom editor with the the atom-html-preview plugin (Ctrl+Shift+H). Anytime you can invoke developer tools pressing by Alt+Command+i. Using MVC Here the most basic Angular+Bootstrap mvc example. In this example, there are three users listed in the ex1 and controller is FriendController which is used as friendList in the HTML. < html > < head > < script src = "https://code.jquery.com/jquery-1.12.0.min.js" > </ script > < script src = "https://code.jquery.com/jquery-migrate-1.2.1.min.js" > </ script > < link rel = "stylesheet" href = "bootstrap-3.3.6-dist/css/bootstrap.css" /> < script type = "text/javascript" src = "angular-1.5.3/angular.js" > </ script > < script type = "text/javascript" src = "bootstrap-3.3.6-dist/js/bootstrap.js...