I want to have template site in AngularJs with /example/car/id where in different ids is a page for different cars . In app.js i wrote :
angular
.module('carApp', [
'ngCookies',
'ngResource',
'ngRoute',
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl'
})
.when('/car/:id', {
templateUrl: 'views/car.html',
controller: 'CarCtrl'
})
});
In Json i made 2 cars:
[{
"model": "Audi",
"year": "1999"
}
{
"model": "BMW",
"year": "2005"
}]
In car.js
angular.module('carApp')
.controller('CarCtrl', ['$scope','$http', function($scope, $http)
{
$http.get('scripts/controllers/cars.json').success (function(data){
$scope.cars = data;
});
}]
);
Where and what code I need to write to have templates where in example/car/1 will show details about Audi and example/car/2 will show details about BMW ?