diff --git a/app.js b/app.js new file mode 100644 index 0000000..ff231dd --- /dev/null +++ b/app.js @@ -0,0 +1,39 @@ +var app = angular.module('myApp', ['ngRoute']); +app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { + //$locationProvider.html5Mode(true); + $routeProvider.when('/furnitures', { + templateUrl: 'furnitures.html', + controller: 'furnitureCtrl' + }).when('/furnitures/:category', { + templateUrl: 'category.html', + controller: 'categoryCtrl' + }).otherwise('/furnitures'); +} +]) +app.controller('categoryCtrl', function($scope, $routeParams) { + $scope.currentCategory = $routeParams.category; + $scope.furnitureCat = { + tables: { + name: 'tables', + furnitures: ['table1', 'table2', 'table3'] + }, + drawers: { + name: 'drawers', + furnitures: ['drawer1', 'drawer2', 'drawer3'] + }, + + } + $scope.currentFurnitures = $scope.furnitureCat[$scope.currentCategory].furnitures; +}) +app.controller('furnitureCtrl', function($scope) { + $scope.furnitureCat = { + tables: { + name: 'tables', + furnitures: [1, 2, 3] + }, + drawers: { + name: 'drawers', + furnitures: [4, 5, 7] + } + } +}) diff --git a/category.html b/category.html new file mode 100644 index 0000000..28a067a --- /dev/null +++ b/category.html @@ -0,0 +1,7 @@ +

Category is: {{currentCategory}}

+ +/img/furnitures/tables/table1.jpg + +

Furniture list

+ +{{furniture}}
\ No newline at end of file diff --git a/furnitures.html b/furnitures.html new file mode 100644 index 0000000..1edc4a2 --- /dev/null +++ b/furnitures.html @@ -0,0 +1,5 @@ +
+ + {{category.name}} + +
diff --git a/index.html b/index.html new file mode 100644 index 0000000..cf876ac --- /dev/null +++ b/index.html @@ -0,0 +1,32 @@ + + + + + + + AngularJS Plunker + + + + + + + + + + + +
+ + + +
+ + +