Angular is a new JavaScript framework from Google. If you are looking into developing rich web applications, Angular is your friend. Angular embraces HTML and CSS, allowing you to extend HTML towards your application, and uses plain JavaScript which makes your code easy to reuse, and test. In this workshop we will start from the ground up, and build our way through a simple application that will let us explore the various constructs, and the familiarize ourselves with some of the new terminology in Angular.
In this workshop we will get down and dirty with Angular. In this workshop we will start with the very basics of how to boostrap our AngularJS application, and work slowly towards making REST-ful AJAX requests to a backend. List of topics include
ng-appng-init and the evaluation {{ }} directive$rootScopeng-modelng-repeatng-form, form validation and submission in AngularJS$http$routeProvider and $routeParamsIf time permits we will discuss a few good practices when working with AngularJS applications.
This is a hands on tutorial so bring your laptops!
This session is a workshop. Please come prepared.
brew install gitMake sure Git is available on your path
Open up a new terminal window
$ git --version
> # Anything greater than 2 will do
> git version 2.1.3
Make sure leiningen is available
$ lein --version
> Leiningen 2.5.1 on Java 1.8.0_40 Java HotSpot(TM) 64-Bit Server VM
If you have an account on Github, feel free to fork the repository and then clone it.
Clone the repository on Github
At a terminal, cd into a directory and run git clone [email protected]:looselytyped/angudone-workshop.git. Note that if you did fork the repository under your account your URL will be something like [email protected]:<YOUR-ACCOUNT-NAME>/angudone-workshop.git
Wake up the application
# at the terminal
# cd to where you cloned the repository above.
$ git checkout master-1.4
$ lein ring server
# This will download a whole bunch of files from Maven Central
# and will end with
# Started server on port 3000
http://localhost:3000/ (If it does not just go to that URL). You should see a HTML page announcing AngudoneEnsure that the REST endpoints are active
Right-Click -> Inspect Element (this will open the Inspector) and then go to the Console tabRight-Click -> Inspect Element (this will open the Chrome Inspector) and then go to the Console tab (right most)Both Consoles give you the ability to run JavaScript code. Run the following
http.get("todos")
.success(function(data, status, headers, config) {
console.log("There are " + data.length + " todos");
}).error(function(data, status, headers, config) {
console.error("Oh Noes! Something went wrong" + data);
});
You should see a a valid response indicated by There are 0 todos
Raju Gandhi is a Java/Ruby/Clojure developer and a programming language geek. He has been writing software for the better part of a decade in several industries including education, finance, construction and the manufacturing sector. Raju has a graduate degree in Industrial Engineering from Ohio University. In his spare time you will find Raju reading, or watching movies, or playing with yet another programming language. He is affectionately known as looselytyped on Twitter.
More About Raju »