Answer the question
In order to leave comments, you need to log in
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>
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: '/'
});
});
app.controller('PhotoCtrl', ['$scope', 'photos', '$routeParam', function ($scope, photos, $routeParam) {
photos.success(function (data) {
$scope.detail = data[$routeParam.id];
});
}]);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question