I am in the process of developing a versatile application with AngularJS.
This is my app.js file:
var app = angular.module('app', ['ngRoute']);
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/', {
templateUrl: '/views/default.html',
controller: 'default'
}).
when('/customers', {
templateUrl: '/views/customers.html',
controller: 'customers'
}).
when('/products/:param', {
templateUrl: '/views/products.html',
controller: 'products'
}).
otherwise({
redirectTo: '/'
});
}]);
The code below is used to navigate to the customers screen.
$scope.openCustomers = function () {
$location.path('/customers');
}
The following code opens the products screen.
$scope.openProducts = function () {
$location.path('/products/123');
}
This snippet contains the customers controller code:
app.controller('customers', ['$scope', function ($scope) {
});
Here is the products controller code:
app.controller('products', ['$scope', '$routeParams', function ($scope,$routeParams) {
$scope.param= $routeParams.param;
});