comment 0

Hello to Angularjs – Part 01

Hey Guys,

I will be starting basic angularjs tutorials. In which I will share different coding examples from scratch.

There will be less explanation as I am not much good in writing big blogs. If you have any questions ask in comments section below. I will get back ASAP.

Step 01:

Add angularjs in the header. It can be downloaded from angularjs.org. Create a second file script.js and add it after angularjs.

<script src="Scripts/angular.min.js"></script>
<script src="Scripts/script.js"></script>

Step 02:

Creating a module and then registering a controller with that module.
In the controller section creating a property message and attaching it to scope object.

// creating module
var myApp = angular
    .module("myModule", [])
// creating controller 
    .controller("myController", function ($scope) {
// creating a message property and attaching it to scope object
        $scope.message = "Hello to Angularjs";
    });

Step 03

ng-app=”” is the starting point of angularjs. Out side this angularjs will not apply as angularjs scope starts/ends with ng-app.

<body ng-app="myModule"></body>

Step 04

ng-controller
Scope of the controller where we can use all functionality of controller.

Step 05

Expression to show value from controller.
{{ message }}

Complete HTML

<body ng-app="myModule">
<div ng-controller="myController">
	Controller: {{ message }}
</div>
</body>

That’s all. You are done with “Hello World” Program using angular.