AngularJS Tutorial - Part 1
In this part, we'll download the required libraries and write a hello world application using AngularJS.
As we are going to develop a web application, we'll need to write HTML, Javascript and CSS. Let's create a directory named 'js' and another named 'css' in the project root directory.
We'll use twitter-bootstrap for the front-end. Let's download the following css files and put them in the css directory that we previously created.
- bootstrap.min.css
- styles.css
bootstrap.min.css is the css library and styles.css contains some custom rules for the template being used in our project. We'll write any other custom css rules in this file.
We are done with css files and it's time to download the required Javascript libraries. Let's download AngularJS library from their website https://angularjs.org/ and put it in the js directory of our project.
Now, we need to write down the HTML file that'll be used as our base template. We'll use one of the templates listed in the twitter-bootstrap's documentation. Here is the link to the template: http://getbootstrap.com/examples/dashboard/
I've removed the unnecessary parts from the HTML, fixed the links to css and js files and put it as index.html in the project root directory. Here is the simplified version https://github.com/rafiqnayan/api-browser/blob/e51a1835cf3afb59c163fc89f5af0d57170461fb/index.html
For simplicity, I'm not going to explain the css styles classes used in the html file. If you are interested to know more about twitter-bootstrap and it's components, you can browse their documentation.
We are done with the library setup and initial structure. If you open the index.html in your browser, you should see the following page
One last thing we'll do in this step is, make sure we've integrated the AngularJS library properly. To do so, we need to modify the index.html file and make these changes https://github.com/rafiqnayan/api-browser/commit/90d1767b11e4c719acca74198ff56265bbca4f45
We've added ng-app inside the html tag. This tells angular to create a AngularJS application whose scope will be the enclosing DOM elements of html tag. AngularJS will parse the DOM and create the application.
By writing {{ 'API' + ' Doc' }}, we are telling angular to join the strings 'API' and ' Doc' and print it.
If you reload the page in your browser you should see same output as before but this time using a bit AngularJS magic! Remove the ng-app from html tag and reload the page to see what happens. Also try changing the {{}} expression and see what happens.
So, in this part, we've done the following
- Downloaded the required CSS and JS library files
- Created a HTML file for project template
- Added AngularJS and declared a AngularJS application using ng-app
- Written a AngularJS expression and performed string concatenation
Next Post: Part 2
Previous Post: Part 0
As we are going to develop a web application, we'll need to write HTML, Javascript and CSS. Let's create a directory named 'js' and another named 'css' in the project root directory.
We'll use twitter-bootstrap for the front-end. Let's download the following css files and put them in the css directory that we previously created.
- bootstrap.min.css
- styles.css
bootstrap.min.css is the css library and styles.css contains some custom rules for the template being used in our project. We'll write any other custom css rules in this file.
We are done with css files and it's time to download the required Javascript libraries. Let's download AngularJS library from their website https://angularjs.org/ and put it in the js directory of our project.
Now, we need to write down the HTML file that'll be used as our base template. We'll use one of the templates listed in the twitter-bootstrap's documentation. Here is the link to the template: http://getbootstrap.com/examples/dashboard/
I've removed the unnecessary parts from the HTML, fixed the links to css and js files and put it as index.html in the project root directory. Here is the simplified version https://github.com/rafiqnayan/api-browser/blob/e51a1835cf3afb59c163fc89f5af0d57170461fb/index.html
For simplicity, I'm not going to explain the css styles classes used in the html file. If you are interested to know more about twitter-bootstrap and it's components, you can browse their documentation.
We are done with the library setup and initial structure. If you open the index.html in your browser, you should see the following page
One last thing we'll do in this step is, make sure we've integrated the AngularJS library properly. To do so, we need to modify the index.html file and make these changes https://github.com/rafiqnayan/api-browser/commit/90d1767b11e4c719acca74198ff56265bbca4f45
We've added ng-app inside the html tag. This tells angular to create a AngularJS application whose scope will be the enclosing DOM elements of html tag. AngularJS will parse the DOM and create the application.
By writing {{ 'API' + ' Doc' }}, we are telling angular to join the strings 'API' and ' Doc' and print it.
If you reload the page in your browser you should see same output as before but this time using a bit AngularJS magic! Remove the ng-app from html tag and reload the page to see what happens. Also try changing the {{}} expression and see what happens.
So, in this part, we've done the following
- Downloaded the required CSS and JS library files
- Created a HTML file for project template
- Added AngularJS and declared a AngularJS application using ng-app
- Written a AngularJS expression and performed string concatenation
Next Post: Part 2
Previous Post: Part 0
Comments
Post a Comment