Tuesday, April 21, 2015

AngularJs example with modules

//////////////////////HTML//////////////////////////////////////


<html>
<title> AngularJs Directives </title>
<head>
<title>Angular JS Table</title>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f2f2f2;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
</style>
</head>
<body>

<div ng-app="myApp">

<div ng-controller="studentController">

{{data.firstname + ' ' + data.lastname }}

<li ng-repeat="item in data.subject">

{{item.name + ' - ' + item.marks}}
<li>

</div>


</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="main.js"></script>
<script src="studentController.js"></script>
</body>
</html>

/////////////////////////////////////main.js////////////////////////////

var myApp=angular.module("myApp",[]);


///////////////////////////////Controller.js///////////////////////////


myApp.controller("studentController",function($scope)
{
$scope.data={
firstname:'Shekhar',
lastname:'Nawale',
subject:[{name:'Physics',marks:'40'},{name:'Math',marks:'45'},{name:'Che',marks:'70'},{name:'Bio',marks:'50'}]
};
});

No comments:

Post a Comment