Greetings, I am currently attempting to create a basic Angular JS program, however, I'm facing some issues with it. Below is the code snippet from my HTML file:
<!DOCTYPE html>
<html data-ng-app="myApp">
<head>
<title>SPA APP</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>
<body>
<div data-ng-view=""></div>
<script src="my-module.js"></script>
<script src="my-controller.js"></script>
</body>
</html>
The following code belongs to my-module.js file:
var myApp=angular.module('myApp',[]);
myApp.config(function($routeProvider){
$routeProvider
.when('/',
{
controller:'myController',
templateUrl:'view1.html'
})
.when('/view2',
{
controller:'myController',
templateUrl:'view2.html'
})
.otherwise({redirectTo:'/'});
});
Lastly, here is the content of my-controller.js file:
myApp.controller('myController',function($scope){
$scope.name="varun";
});
I would greatly appreciate any assistance or guidance provided. Thank you.