KEMBAR78
Web tools - angular js | PDF
KARTHIKEYAN P
Web Development Tools
Session 3
KARTHIKEYAN P
Session Outcomes
At the end of this session, students will be able to,
1. Install and use angular js
2. Run a simple app using angular js
KARTHIKEYAN P
Angular JS
• Download Angular JS
– (https://angularjs.org)
– Use angular.min.js
KARTHIKEYAN P
Angular JS
• Files
– index.html, app.js, angular.min.js
– style.css (optional)
• Wrapping your AngularJS components in an
Immediately Invoked Function Expression
(IIFE). This helps to prevent variables and
function declarations from living longer than
expected in the global scope, which also helps
avoid variable collisions.
https://codestyle.co/guidelines/angularjs/
KARTHIKEYAN P
app.js
//IIFE
(function(){
'use strict';
angular.module('myFirstApp',[ ])
.controller('MyFirstController', function() {
});
})();
KARTHIKEYAN P
Update index.html
• Add angualar app
<html ng-app=“myFirstApp”>
• Add angular controller
<div ng-controller=“myFirstController”>
KARTHIKEYAN P
app.js
(function(){
'use strict';
angular.module('myFirstApp',[])
.controller('MyFirstController', function($scope) {
$scope.name = “karthik”
$scope.sayHello = function() { return “Hai”;}
});
})();
KARTHIKEYAN P
Sharing data - controller
• Add angular controller
<div ng-controller=“myFirstController”>
{{name}}
{{sayHello()}}
</div>
KARTHIKEYAN P
Sharing data - controller
• Add angular controller
<div ng-controller=“myFirstController”>
<input type="text" ng-model="name">
Inside input box is: {{name}}
</div>
KARTHIKEYAN P
QUIZ

Web tools - angular js