This example demonstrate the code sample for Hello World program. Copy and paste the code in your html file and you could get started ASAP. The sample code also consists of bootstrap code for creating decent UI fields.
Instruction: Type your name in the text field below:

Hello {{name}}! How are you doing today?


  • ng-app directive such as ng-app="helloApp" with <html> tag is used to initialize the module.
  • ng-controller directive such as ng-controller="HelloCtrl" in the <body> tag is used to name the controller. The ng-controller directive can be used with div container as well.
  • ng-model directive such as ng-model="name" is used in the input field to data-bind the input with the model named as "name"
  • Template is written with double curly braces and the model name within.
  • The controller code is written inside <script> within <head> section
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<html ng-app="helloApp">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello AngularJS - Hello World</title>
<link rel="stylesheet"
	var helloApp = angular.module("helloApp", []);
	helloApp.controller("HelloCtrl", function($scope) {
		$ = "Calvin Hobbes";
<body ng-controller="HelloCtrl">
	<header class="navbar navbar-static-top" id="top" role="banner">
	<div class="container">
		<div class="navbar-header">
			<button class="navbar-toggle" type="button" data-toggle="collapse"
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
			<a href="/" class="navbar-brand">Hello-AngularJS</a>
	<div class="container">
		<div class="page-header" style="margin: 0">
			<h1>Hello World</h1>
		<div style="padding-top: 15px">This example demonstrate the code
			sample for Hello World program. Type your name in the text field
		<div style="padding-top: 30px">
			<div style="padding: 0px 0px 20px 30px">
				<h4>Hello {{name}}! How are you doing today</h4></div>
			<form class="form-horizontal" role="form" method="post" action="#">
				<div class="form-group">
					<label class="col-md-1 control-label">Name</label>
					<div class="col-md-3">
						<input type="text" class="form-control" name="firstname"
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">Notes</h3>
			<div class="panel-body">Pay attention to ng-model="name" and the template {{name}}</div>
comments powered by Disqus