Saturday, June 25, 2016
The previous blog post we setup the AngularJS folder structure and pulled in the necessary dependencies using bower. In this post we are going to add AngularJS to our application. We will app an AngularJS application and controller to our simple banking application.
Here are the steps to setup AngularJS in our application.
1. Create an app.js file in the app/js folder, app.css in the app/css folder
The source code for the app.js file should look like the following
The code above defines the application name 'bankApp', and the modules that the application is dependent on ['bankController'] in this case the application is dependent on the bankController module. In the next step we will create the controller for the bankApp application
2. Add a folder in the "js" folder and call it "controllers" then create a file call "bankController.js" in the "controllers" folder and source code for the file should look like the following
The code above registers a new module called bankcontroller with no dependencies. The controller itself passes in the angular object $scope. The $scope object in angular act as a conduit between the view and the controller. Meaning anything that is defined in the $scope object is accessible in the view (.html) page. In the example above we defined a variable in the $scope object call "bankAppName". Since it's defined in the controller we can now access the data from our view (index.html) page. Now we are ready to make some changes to our "index.html" page to make this an angularJS SPA application.
3. The source code file "index.html" should look like the following
The code above provides the plumbing for our SPA application. It's written using the HTML5 template format so that it is HTML5 compliant. The app.css contains all the styles associated with the application, the "angular.js" file contains the angularJS library framework. The "app.js" file contains the JavaScript codes that will be used for this application. The "controller.js" file contains the controller for the application.
AngularJS uses the MVC framework, Model-View-Controller. Basically they all work together to make the application work. In a simple explanation the model is the data, the view is what the users see, and the controller is the flow of the application. The next step is the define our application in the app.js file.
4. Open up the "index.html" file and make sure the source code looks like the following.
All we want to see that our $scope.bankAppName AngularJS variable can be accessed in our index.html file.
5. Now open the index.html file in a browser to see that AngularJS is set up correctly
In this tutorial we've taken care of the plumbing in an AngularJS application. We gave created a module, associate a controller, define a variable in the controller's scope and then display the scope variable in a view. We basically have all of the AngularJS app components working.
github: https://github.com/techjunkiejh/ACMEBank/tree/Setup
Posts In The AngularJS SPA Application Series:
Here are the steps to setup AngularJS in our application.
1. Create an app.js file in the app/js folder, app.css in the app/css folder
The source code for the app.js file should look like the following
'use strict'; angular.module('bankApp',['bankController']);
The code above defines the application name 'bankApp', and the modules that the application is dependent on ['bankController'] in this case the application is dependent on the bankController module. In the next step we will create the controller for the bankApp application
2. Add a folder in the "js" folder and call it "controllers" then create a file call "bankController.js" in the "controllers" folder and source code for the file should look like the following
'use strict'; angular.module('bankController',[]) .controller('bankController',["$scope",function($scope){ $scope.bankAppName="ACME Bank"; }]);
The code above registers a new module called bankcontroller with no dependencies. The controller itself passes in the angular object $scope. The $scope object in angular act as a conduit between the view and the controller. Meaning anything that is defined in the $scope object is accessible in the view (.html) page. In the example above we defined a variable in the $scope object call "bankAppName". Since it's defined in the controller we can now access the data from our view (index.html) page. Now we are ready to make some changes to our "index.html" page to make this an angularJS SPA application.
3. The source code file "index.html" should look like the following
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>ACME Bank</title> <link rel="stylesheet" type="text/css" href="css/app.css"> </head> <body> <script type="text/javascript" src="js/lib/angular/angular.js"></script> <script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/controllers/bankController.js"></script> </body> </html>
The code above provides the plumbing for our SPA application. It's written using the HTML5 template format so that it is HTML5 compliant. The app.css contains all the styles associated with the application, the "angular.js" file contains the angularJS library framework. The "app.js" file contains the JavaScript codes that will be used for this application. The "controller.js" file contains the controller for the application.
AngularJS uses the MVC framework, Model-View-Controller. Basically they all work together to make the application work. In a simple explanation the model is the data, the view is what the users see, and the controller is the flow of the application. The next step is the define our application in the app.js file.
4. Open up the "index.html" file and make sure the source code looks like the following.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>ACME Bank</title> <link rel="stylesheet" type="text/css" href="app.css"> </head> <body ng-app="acmeBank" ng-controller="bankController"> {{bankAppName}} <script type="text/javascript" src="js/lib/angular/angular.js"></script> <script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/controllers/bankController.js"></script> </body> </html>
All we want to see that our $scope.bankAppName AngularJS variable can be accessed in our index.html file.
5. Now open the index.html file in a browser to see that AngularJS is set up correctly
github: https://github.com/techjunkiejh/ACMEBank/tree/Setup
Posts In The AngularJS SPA Application Series:
- AngularJS SPA : Setting Up ACME Bank
- AngularJS SPA : Preparing AngularJS For Banking Application
- Refactor Code to Not Use Global Variables (ACME App)
- Installing MongoDB
- Create a MongoDB Configuration FIle
- Install mongoDB as a Windows Service
- Installing Express generator
- Installing ExpressJS Application Server
- Creating The SPA Project Folder Structure
- Setup Express To Serve Static Files
- Setup The ACME Bank Application For Heroku And Testing It Locally
- Deploy ACME Bank Application To Heroku
- Install RoboMongo GUI for MongoDB
Subscribe to:
Post Comments (Atom)
Search This Blog
Tags
Web Development
Linux
Javascript
DATA
CentOS
ASPNET
SQL Server
Cloud Computing
ASP.NET Core
ASP.NET MVC
SQL
Virtualization
AWS
Database
ADO.NET
AngularJS
C#
CSS
EC2
Iaas
System Administrator
Azure
Computer Programming
JQuery
Coding
ASP.NET MVC 5
Entity Framework Core
Web Design
Infrastructure
Networking
Visual Studio
Errors
T-SQL
Ubuntu
Stored Procedures
ACME Bank
Bootstrap
Computer Networking
Entity Framework
Load Balancer
MongoDB
NoSQL
Node.js
Oracle
VirtualBox
Container
Docker
Fedora
Java
Source Control
git
ExpressJS
MySQL
NuGet
Blogger
Blogging
Bower.js
Data Science
JSON
JavaEE
Web Api
DBMS
DevOps
HTML5
MVC
SPA
Storage
github
AJAX
Big Data
Design Pattern
Eclipse IDE
Elastic IP
GIMP
Graphics Design
Heroku
Linux Mint
Postman
R
SSL
Security
Visual Studio Code
ASP.NET MVC 4
CLI
Linux Commands
Powershell
Python
Server
Software Development
Subnets
Telerik
VPC
Windows Server 2016
angular-seed
font-awesome
log4net
servlets
tomcat
AWS CloudWatch
Active Directory
Angular
Blockchain
Collections
Compatibility
Cryptocurrency
DIgital Life
DNS
Downloads
Google Blogger
Google Chrome
Google Fonts
Hadoop
IAM
KnockoutJS
LINQ
Linux Performance
Logging
Mobile-First
Open Source
Prototype
R Programming
Responsive
Route 53
S3
SELinux
Software
Unix
View
Web Forms
WildFly
XML
cshtml
githu
The day spa, which has been deliberately intended to make a feeling of warmth and joyful unwinding, helps a sumptuous pool, restorative hydrotherapy pool, sauna and steam rooms inventive wellness suite and studio, and Rasul mud room, just as a scope of comprehensive spa medications.
ReplyDeleteメンズエステ出張
The Best Essay Writing Service in The UK We created a dynamic and flexible system that allows students from all over the UK a
ReplyDeleteThis is a very nice one and gives in-depth information. I am really happy with the quality and presentation of the article. I’d really like to appreciate the efforts you get with writing this post. Thanks for sharing.Java training in Bangalore
ReplyDeleteHello, I would like to thank you for sharing this useful material. The info related to banking applications might be useful for those who are interested in this sphere. While studying at university I had an economy course and thanks to the source I found online I managed to do my excel homework https://mid-terms.com/do-my-excel-assignment/ on time and pass my project successfully
ReplyDeleteAivivu chuyên vé máy bay, tham khảo
ReplyDeletevé máy bay đi Mỹ giá bao nhiêu
vé máy bay từ mỹ về việt nam mùa dịch
giá vé máy bay từ Vancouver về việt nam
vé máy bay từ nhật về vn
vé máy bay vietjet từ hàn quốc về việt nam
Vé máy bay từ Đài Loan về VN
Chuyến bay cho chuyên gia nước ngoài
Mua vé máy bay tại Aivivu, tham khảo
ReplyDeletekinh nghiệm mua vé máy bay đi Mỹ giá rẻ
gia ve may bay ve vn
vé máy bay từ canada về việt nam bao nhiêu tiền
mở chuyến bay từ nhật về việt nam
ve may bay tu han quoc ve viet nam
Vé máy bay từ Đài Loan về Việt Nam
Chi phí cho chuyên gia nước ngoài
Oh guys! This is it! I know how cool it is so vhek this essay writer for you adn be the best!Enjoy your day and be happy my freind! Love it! This is very nice! Good lcuk!
ReplyDelete