Routing in angular js

app.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/', {
title: 'Customers',
templateUrl: 'partials/customer/customers.html',
controller: 'listCustomerCtrl'
})
.when('/properties', {
title: 'Properties',
templateUrl: 'partials/property/properties.html',
controller: 'listPropertyCtrl'
})
.when('/edit-customer/:customerID', {
title: 'Edit Customers',
templateUrl: 'partials/customer/edit-customer.html',
controller: 'editCustomerCtrl',
resolve: {
customer: function(user_services, $route){
var customerID = $route.current.params.customerID;
return user_services.getCustomer(customerID);
}
}
})
.when('/edit-property/:p_id', {
title: 'Edit Property',
templateUrl: 'partials/property/edit-property.html',
controller: 'editPropertyCtrl',
resolve: {
property: function(property_services, $route){
var p_id = $route.current.params.p_id;
return property_services.getProperty(p_id);
}
}
})
.otherwise({
redirectTo: '/'
});
}]);

Share This:

Leave a Reply

Your email address will not be published. Required fields are marked *