var myController= function( $scope )
{
$scope.message=”Welcome at CareerRide”;
};
File Name: Script.js in Scripts folder.
/// <reference path="angular.min.js" />
var myApp = angular.module("myModule", []); //Creating a module
var myController = function ($scope) //Creating a controller
{
$scope.message = "Welcome at CareerRide";
};
myApp.controller("myCont",myController); //Registering the controller with Module.
myApp.controller("myCont", function ($scope)
{
$scope.message = "Welcome at CareerRide";
});
<!DOCTYPE html/>
<html ng-app="myModule">
<head>
<script src="Scripts/angular.min.js" type="text/javascript"></script>
<script src="Scripts/Script.js" type="text/javascript"></script>
</head>
<body>
<div ng-controller="myCont">
{{message}}
</div>
</body>
</html>
<!DOCTYPE html/>
<html ng-app="myApp">
<head>
<script src="Scripts/angular.min.js" type="text/javascript"></script>
</head>
<body>
<div ng-controller="myCont">
{{message}}
</div>
<div>
{{message}}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCont", function ($scope)
{
$scope.message = "Hello World !!";
});
</script>
</body>
</html>
var Employee = {
FirstName: "Raj",
LastName: "Parihar",
Gender: "Male"
};
File Name: Script.js in Scripts folder.
/// <reference path="angular.min.js" />
var myApp = angular.module("myModule", []);
var myController = function ($scope)
{
var Employee = {
FirstName: "Raj",
LastName: "Parihar",
Gender: "Male"
};
$scope.Emp = Employee;
};
myApp.controller("myCont",myController);
<!DOCTYPE html/>
<html ng-app="myModule">
<head>
<script src="Scripts/angular.min.js" type="text/javascript"></script>
<script src="Scripts/Script.js"></script>
<style>
table, th, td
{
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd)
{
background-color: #ffe6e6;
}
table tr:nth-child(even)
{
background-color: #ccffcc;
}
</style>
</head>
<body>
<div ng-controller="myCont">
<table border="0">
<tr>
<td>FirstName:</td><td>{{Emp.FirstName}}</td>
</tr>
<tr>
<td>LastName:</td><td>{{Emp.LastName}}</td>
</tr>
<tr>
<td> Gender:</td><td>{{Emp.Gender}}</td>
</tr>
</table>
</div>
</body>
</html>