A
A
Alexander2016-01-14 19:24:52
JavaScript
Alexander, 2016-01-14 19:24:52

What's wrong with ($routeProvider)?

<!DOCTYPE html>
<html lang="en">
<base href="/">
<head>
    <meta charset="UTF-8">
    <title>AngularJs</title>
    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
    <script src="bower_components/angular/angular.min.js"></script>
    <script src="js/angular-route.min.js"></script>
</head>
<body ng-app="Application" ng-controller="MainCtrl">
<div class="container">
    <div ng-view></div>
</div>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!--App-->
<script src="js/app.js"></script>
<!--Controller-->
<script src="js/controllers/MainController.js"></script>
<!--Services-->
<script src="js/services/get.js"></script>
</body>
</html>

app.js :
var app = angular.module('Application', ['ngRoute']);
app.config(function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
    $routeProvider
        .when('/', {
            controller: 'MainCtrl',
            templateUrl: 'views/app.html'
        })
        .when('/photo/:id', {
            controller: 'PhotoCtrl',
            templateUrl: 'views/photo.html'
        })
        .otherwise({
            redirectTo: '/'
        });
});

PhotoController :
app.controller('PhotoCtrl', ['$scope', 'photos', '$routeParam', function ($scope, photos, $routeParam) {
    photos.success(function (data) {
        $scope.detail = data[$routeParam.id];
    });
}]);

Error:
23a8c53c.jpg
Help me find where I did something wrong? most likely I think that I did not connect it.
Server: Xampp.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-01-14
@kentuck1213

I bet you forgot to connect PhotoController.js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question