Hey there! I'm in need of some assistance. Just started learning Angular and tried setting it up like this.
This is the structure of my files:
AboutController.js
function AboutController( $scope ){
$scope.data = {
"data" : {
"name" : "nameku",
"email" : "email.com"
},
"data" : {
"name" : "nameku2",
"email" : "email2.com"
}
}
}
about.html
<script type="text/javascript" src="controllers/AboutController.js"></script>
<div ng-controller="AboutController">
<ul ng-repeat="d in data">
<li>{{d.name}}</li>
</ul>
</div>
index.html
<html ng-app="TestingAngular">
<head>
<title>TestingAngular Dashboard</title>
</head>
<script type="text/javascript" src="components/angular/angular.min.js"></script>
<script type="text/javascript" src="components/angular-route/angular-route.min.js"></script>
<script type="text/javascript" src="route.js"></script>
<body>
<div ng-view></div>
</body>
</html>
route.js
angular.module('TestingAngular', ['ngRoute'])
.config( function( $routeProvider ){
$routeProvider
.when(
'/about' , {templateUrl: 'views/about.html'}
)
.when(
'/contact' , {templateUrl: 'views/contact.html'}
)
.when(
'/' , {templateUrl: 'views/home.html'}
);
});
I'm facing an issue where I receive the following error. Is there a way to make it work as intended?
When I move the
<script type="text/javascript" src="controllers/AboutController.js"></script>
to index, it seems to work fine. Please advise if I am on the right track.
Error: [ng:areq] http://errors.angularjs.org/1.2.25/ng/areq?p0=AboutController&p1=not%20aNaNunction%2C%20got%20undefined at Error (native)