I am teaching myself angular.js and have run into a problem today and was
hoping someone could take a quick look at my code and help me out a little
bit. The problem that i am running into is that i have hit a snag with
creating routes. I have two similar pages, and keep hitting 404's when i
fire up the app in my local host. I feel like i am close because
everything is being read, and i have no errors within the console, but i
still have yet to get the entire routes to properly operate. I would be
very grateful if anybody could take a quick look at my code below and see
if there is anything that i need to alter to fix.
Below is my app.js file. I feel like if there is anything that I have made
a mistake with, it would be this one, but i'm not entirely sure.
var app = angular.module('myApp', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider
.when('/index/', {
controller: 'MainController',
templateUrl: 'views/home.html'
})
.when('/test/', {
controller: 'testController',
templateUrl: 'views/home.html'
})
.otherwise({
redirectTo: '/'
});
});
These are the two html pages that i have within my views. They essentially
are the same, i just have different controllers associated with them. The
first one is called test, and the second one is called index
<div class="main" ng-controller="testController">
<div class="container">
<h1>{{ title }}</h1>
<div ng-repeat="product in products" class="col-md-6">
<product-info product="product"></product-info>
</div>
</div>
</div>
</div>
<div class="main" ng-controller="MainController">
<div class="container">
<h1>{{ title }}</h1>
<div ng-repeat="product in products" class="col-md-6">
<product-info product="product"></product-info>
</div>
</div>
</div>
</div>
Finally, here is my general views index page:
<!doctype html>
<html>
<head>
<link href="css/main.css" rel="stylesheet" />
<script src="js/shared/angular.min.js"></script>
<script
src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script>"
</head>
<body ng-app="myApp">
<div class="header">
<div class="container">
<h1>Stadiums in various leagues</h1>
</div>
</div>
<div class="footer">
<div class="container">
</div>
<script src="js/app.js"></script>
<script src="js/controllers/MainController.js"></script>
<script src="js/directives/productInfo.js"></script>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.