add files
parent
88eff5001b
commit
239b850d63
@ -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]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -0,0 +1,7 @@
|
|||||||
|
<h3> Category is: {{currentCategory}}</h3>
|
||||||
|
|
||||||
|
/img/furnitures/tables/table1.jpg
|
||||||
|
|
||||||
|
<h4>Furniture list</h4>
|
||||||
|
|
||||||
|
<a href="/img/furnitures/{{currentCategory}}/{{furniture}}.jpg" ng-repeat="furniture in currentFurnitures">{{furniture}}<br /></a>
|
@ -0,0 +1,5 @@
|
|||||||
|
<div ng-repeat="category in furnitureCat">
|
||||||
|
|
||||||
|
<a href="#/furnitures/{{category.name}}">{{category.name}}</a>
|
||||||
|
|
||||||
|
</div>
|
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>AngularJS Plunker</title>
|
||||||
|
<script>document.write('<base href="' + document.location + '" />');</script>
|
||||||
|
<link rel="stylesheet" href="style.css" />
|
||||||
|
<script data-require="angular.js@1.5.x" src="https://code.angularjs.org/1.5.8/angular.js" data-semver="1.5.8"></script>
|
||||||
|
<script data-require="angular-route@1.5.8" data-semver="1.5.8" src="https://code.angularjs.org/1.5.8/angular-route.js"></script>
|
||||||
|
<script src="app.js"></script>
|
||||||
|
<script src='http://127.0.0.1:9001/js/socket.js'></script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
#furniture {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 40vh;
|
||||||
|
border: 1px solid red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div ng-view ng-app="myApp" id="furniture">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Reference in New Issue