AngularJS Slip no 2 Solution

<html ng-app="courseApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="CourseController" ng-init="initialize()">
<h1>Course List</h1>
<h2>Undergraduate Courses</h2>
<ol>
<li ng-repeat="course in undergraduateCourses">{{ $index + 1 }}. {{ course }}</li>
</ol>
<h2>Post Graduate Courses</h2>
<ol>
<li ng-repeat="course in postGraduateCourses">{{ $index + 1 }}. {{ course }}</li>
</ol>
<script>
var app = angular.module('courseApp', []);
app.controller('CourseController', function ($scope) {
$scope.undergraduateCourses = [];
$scope.postGraduateCourses = [];
$scope.initialize = function () {
$scope.undergraduateCourses = ['BBA(CA)', 'BCA(Science)', 'B.Sc.(Computer Science)'];
$scope.postGraduateCourses = ['M.Sc.(Computer Science)', 'M.Sc.(CA)', 'MCA'];
};
});
</script>
</body>
</html>

No comments:

Post a Comment