It can be added to an HTML page with a <script> tag.
Let's look at a example.
javascript.js
index.html
Angular JS modules define applications.Module is a container for the different parts of an
application.It is a container for the application controllers.A module is created using angular.module function.Here module name is myApp.[] is used for injecting dependencies.But here we keeps it empty.
Angular JS controllers control applications. Controller is referring using ng-controller directive in HTML file.The ng-controller="myCtrl" attribute is an AngularJS directive. It defines a controller.Here $scope is the application object.Here controller creates two variables called firstName and lastname in the scope. ng-model directives bind the input fields to the controller.
The AngularJS application is defined by ng-app="myApp".AngularJS expressions can be written inside double braces.AngularJS will resolve the expression, and return the result exactly where the expression is written.Expressions are much like JavaScript expressions.Inside {{}} we can give mathematical expressions too.like {{5+5}}.AngularJS outputs the answer as 10.
var app = angular.module('myApp', []);
Angular JS controllers control applications. Controller is referring using ng-controller directive in HTML file.The ng-controller="myCtrl" attribute is an AngularJS directive. It defines a controller.Here $scope is the application object.Here controller creates two variables called firstName and lastname in the scope. ng-model directives bind the input fields to the controller.
app.controller('myCtrl', function($scope) { $scope.firstName= "Little"; $scope.lastName= "John"; });
The AngularJS application is defined by ng-app="myApp".AngularJS expressions can be written inside double braces.AngularJS will resolve the expression, and return the result exactly where the expression is written.Expressions are much like JavaScript expressions.Inside {{}} we can give mathematical expressions too.like {{5+5}}.AngularJS outputs the answer as 10.
No comments:
Post a Comment