Skip to content

Instantly share code, notes, and snippets.

@duycuong87vn
Created April 18, 2014 08:57
Show Gist options
  • Save duycuong87vn/11032669 to your computer and use it in GitHub Desktop.
Save duycuong87vn/11032669 to your computer and use it in GitHub Desktop.
var productCtrl = angular.module('productCtrl', []);
productCtrl.controller('fashionCtrl', ['$scope', '$http',
function($scope, $http) {
$http.get('js/temporaryData/fashions.json').success(function(data) {
$scope.fashions = data;
});
}
]);
/**
* product module
* [productApp description]
* create the module and name it productApp
* include ngRoute for all our routing needs
*/
// two modules 'ngRoute' and 'productCtrl' as dependencies of productApp
// can use the directives and servces they provice
// ['ngRoute', 'productCtrl'] is array lists the modules productApp depends on.
var productApp = angular.module('productApp', [
'ngRoute',
'productCtrl'
]);
// configure route
productApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider
// route for category
.when('/category', {
templateUrl: '../web/partials/category.html',
controller: 'fashionCtrl'
})
// route for product item
// productID is a variable part of the URL
// All variables defined with the : notation are extracted into the $routeParams object.
/*.when('/product/:productID', {
templateUrl: '../web/partials/product-item.html',
controller: 'productItemCtrl'
})*/
// route for otherwise
otherwise({
redirectTo: '/fashions'
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment