-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ayaskant Sahu
committed
Feb 22, 2015
1 parent
71f2cde
commit b18400e
Showing
18 changed files
with
784 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<h3>AngularJS experiments</h3> | ||
|
||
<p> | ||
AngularJS can be a complete framework on the UI side with features like routing, services and dependency injection integrated into it | ||
</p> | ||
|
||
<ol> | ||
<li> | ||
AngularSJ Routing | ||
</li> | ||
<li> | ||
A sample service and dependency injection was done to demonstrate login feature | ||
</li> | ||
<li> | ||
Login feature was improved by using $cookieStorage module | ||
</li> | ||
<li> | ||
More features were added and data sharing was achived betweendifferent controllers. Child controllers were spawned under a parent controller as well. | ||
</li> | ||
<li> | ||
AngularJS-UI google maps | ||
</li> | ||
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
week1/week1.html?week1.txt Week 1 - HTML5 | ||
week2/week2.html?week2.txt Week 2 - CSS and Bootstrap | ||
week2/week2.html?week2.txt Week 2 - CSS and Bootstrap | ||
week3/week3.html?week3.txt Week 3 - Jquery | ||
week4/week4.html?week4.txt Week 4 - AngularJS | ||
week5/week5.html?week5.txt Week 5 - AngularJS - Routing, Services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
||
<title>Starter Node and Angular</title> | ||
|
||
<!-- CSS --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
<link rel="stylesheet" href="css/style5.css"> <!-- custom styles --> | ||
<!-- JS --> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-route.min.js"></script> | ||
|
||
<!-- ANGULAR CUSTOM --> | ||
<script src="js/app1.js"></script> | ||
</head> | ||
<body ng-app="RestCentralApp" ng-controller="parentController" class="container"> | ||
<fieldset> | ||
<div> | ||
<!-- HEADER --> | ||
<nav class="navbar navbar-inverse"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="#">Rest Central</a> | ||
</div> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="#/addApp">Add Application</a></li> | ||
<li><a href="#/login">Login</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<!-- ANGULAR DYNAMIC CONTENT --> | ||
<div ng-view></div> | ||
|
||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>About the experiment</h3> | ||
<div> | ||
The magic of Routing is taken care by a service provider that Angular provides out of the box called $routeProvider. An Angular service is a singleton object created by a service factory. These service factories are functions which, in turn, are created by a service provider. The service providers are constructor functions. When instantiated they must contain a property called $get, which holds the service factory function. | ||
|
||
When we use AngularJS’s dependency injection and inject a service object in our Controller, Angular uses $injector to find corresponding service injector. Once it get a hold on service injector, it uses $get method of it to get an instance of service object. Sometime the service provider needs certain info in order to instantiate service object. | ||
|
||
In this case, clicking on the links loads the partian wab pages by making internal ajax calls. | ||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Code Snippets</h3> | ||
This line gets the app and injects the route service into it. Thus it can be used to define all the routes for the application. | ||
<pre> | ||
angular.module('RestCentralApp').config(['$routeProvider', function($routeProvider) | ||
</pre> | ||
<br /> | ||
<br /> | ||
This chunk of code is responsible for routing all requests with addApp to the path provided. Thus it loads the partial internally. | ||
<pre> | ||
$routeProvider.when('/addApp', { | ||
templateUrl: 'views/AddApp.html' | ||
}) | ||
</pre> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Source Code</h3> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/Experiment1.html" target="_blank">html</a> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/js/app1.js" target="_blank">js</a> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>References</h3> | ||
<a href="http://www.w3schools.com/" target="_blank">W3 Schools</a> | ||
</fieldset> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
||
<title>Starter Node and Angular</title> | ||
|
||
<!-- CSS --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
<link rel="stylesheet" href="css/style5.css"> <!-- custom styles --> | ||
<!-- JS --> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-route.min.js"></script> | ||
|
||
<!-- ANGULAR CUSTOM --> | ||
<script src="js/app2.js"></script> | ||
</head> | ||
<body ng-app="RestCentralApp" ng-controller="parentController" class="container"> | ||
<fieldset> | ||
<div> | ||
<a href="#" ng-click="logOut()" class="btn btn-danger" style="margin-left: 93.2%;" ng-show="loggedIn">Log Out</a> | ||
<!-- HEADER --> | ||
<nav class="navbar navbar-inverse"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="#">Rest Central</a> | ||
</div> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="#/addApp">Add Application</a></li> | ||
<li><a href="#/login">Login</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<!-- ANGULAR DYNAMIC CONTENT --> | ||
<div ng-view></div> | ||
|
||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>About the experiment</h3> | ||
<div> | ||
In Angular a service is a function or an object and is used to share data and/or behavior across controllers, directives, filters, other services etc. A service is treated as a singleton, that is there is only one instance of a specific service available during the whole lifetime of the Angular application. This is different from e.g. a controller of which many instances can be created. | ||
|
||
In this case, logging in using the credentials "user" and "password" maintains a session for the user and shows the log out button | ||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Code Snippets</h3> | ||
This line creates the service in the scope of the application. | ||
<pre> | ||
angular.module('RestCentralApp').service("RestCentralService", function ($http, $q) {} | ||
</pre> | ||
<br /> | ||
<br /> | ||
This line injects the serviec into the desired controller for usage | ||
<pre> | ||
app.controller('parentController', function ($scope, RestCentralService, $window) | ||
</pre> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Source Code</h3> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/Experiment2.html" target="_blank">html</a> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/js/app2.js" target="_blank">js</a> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>References</h3> | ||
<a href="http://www.w3schools.com/" target="_blank">W3 Schools</a> | ||
</fieldset> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
|
||
<title>Starter Node and Angular</title> | ||
|
||
<!-- CSS --> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css"> | ||
<link rel="stylesheet" href="css/style5.css"> <!-- custom styles --> | ||
<!-- JS --> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.min.js"></script> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-route.min.js"></script> | ||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-cookies.js"></script> | ||
|
||
<!-- ANGULAR CUSTOM --> | ||
<script src="js/app3.js"></script> | ||
</head> | ||
<body ng-app="RestCentralApp" ng-controller="parentController" class="container"> | ||
<fieldset> | ||
<div> | ||
<a href="#" ng-click="logOut()" class="btn btn-danger" style="margin-left: 93.2%;" ng-show="loggedIn">Log Out</a> | ||
<!-- HEADER --> | ||
<nav class="navbar navbar-inverse"> | ||
<div class="navbar-header"> | ||
<a class="navbar-brand" href="#">Rest Central</a> | ||
</div> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="#/addApp">Add Application</a></li> | ||
<li><a href="#/login">Login</a></li> | ||
</ul> | ||
</nav> | ||
|
||
<!-- ANGULAR DYNAMIC CONTENT --> | ||
<div ng-view></div> | ||
|
||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>About the experiment</h3> | ||
<div> | ||
As an improvement over the normal way of storing user session, $cookieStorage was used. In general the normal js session is wiped out when the broweser is refreshed, but <b>cookie storage ensures persistent session storage in this case.</b> | ||
$cookieStrorage Provides a key-value (string-object) storage, that is backed by session cookies. Objects put or retrieved from this storage are automatically serialized or deserialized by angular's toJson/fromJson. | ||
<br/> | ||
In this case, logging in using the credentials "user" and "password" maintains a session for the user and shows the log out button | ||
</div> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Code Snippets</h3> | ||
This line includes the cookies dependency into the module | ||
<pre> | ||
angular.module('RestCentralApp', ['ngRoute', 'ngCookies']); | ||
</pre> | ||
<br /> | ||
<br /> | ||
These lines show how the user session is stored into cookies and fetched from cookies to ensure consistency even on page refresh. | ||
<pre> | ||
$cookieStore.put('loggedIn', true); | ||
$cookieStore.get('loggedIn'); | ||
</pre> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>Source Code</h3> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/Experiment3.html" target="_blank">html</a> | ||
<a href="../../fileview/Default.aspx?~/experiments/week5/js/app3.js" target="_blank">js</a> | ||
</fieldset> | ||
<br /> | ||
<br /> | ||
<fieldset> | ||
<h3>References</h3> | ||
<a href="http://www.w3schools.com/" target="_blank">W3 Schools</a> | ||
</fieldset> | ||
</body> | ||
</html> |
Oops, something went wrong.