{{event.name}}
+{{event.description}}
+ Price: {{event.price}} +diff --git a/bower.json b/bower.json index 9401feb..7ef3e26 100644 --- a/bower.json +++ b/bower.json @@ -9,6 +9,8 @@ "private": true, "dependencies": { "angular": "~1.4.8", + "angular-route": "~1.4.9", + "angular-resource": "~1.4.9", "jquery": "~2.2.0", "lodash": "~4.0.0" } diff --git a/grunt/config/concat.js b/grunt/config/concat.js index 5652ee9..615541a 100644 --- a/grunt/config/concat.js +++ b/grunt/config/concat.js @@ -4,6 +4,8 @@ module.exports = { '<%= general.tempDir %>/libs.js': appendLibsPath([ 'jquery/dist/jquery.js', 'angular/angular.js', + 'angular-route/angular-route.js', + 'angular-resource/angular-resource.js', 'lodash/lodash.js', ]) } diff --git a/grunt/config/copy.js b/grunt/config/copy.js new file mode 100644 index 0000000..900a088 --- /dev/null +++ b/grunt/config/copy.js @@ -0,0 +1,10 @@ +module.exports = { + html: { + expand: true, + cwd: 'src/templates/', + src: '*', + dest: 'public/templates/', + filter: 'isFile', + flatten: true, + }, +}; diff --git a/grunt/tasks/build.js b/grunt/tasks/build.js index 99a5b27..3c08d70 100644 --- a/grunt/tasks/build.js +++ b/grunt/tasks/build.js @@ -1,3 +1,3 @@ module.exports = function (grunt) { - grunt.registerTask('build', ['concat']); + grunt.registerTask('build', ['concat','copy:html']); }; diff --git a/package.json b/package.json index 2e71298..4024dc1 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "express": "~4.13.1", "grunt": "^0.4.5", "grunt-contrib-concat": "^0.5.1", + "grunt-contrib-copy": "^0.8.2", "grunt-contrib-jshint": "^0.12.0", "grunt-contrib-watch": "^0.6.1", "jade": "~1.11.0", @@ -24,6 +25,7 @@ "serve-favicon": "~2.3.0" }, "devDependencies": { + "grunt-contrib-copy": "^0.8.2", "grunt-contrib-jshint": "^0.12.0", "grunt-contrib-watch": "^0.6.1" } diff --git a/routes/api.js b/routes/api.js index f7d97e6..cae1a3a 100644 --- a/routes/api.js +++ b/routes/api.js @@ -8,4 +8,24 @@ router.get('/psy', function(req, res, next) { }); }); +router.get('/events-list', function(req, res, next) { + var eventList = [ + { + "id": "event-1", + "image": "http://community.stagephod.com/wp-content/uploads/2015/02/Events-stagephod.jpg", + "name": "First Event", + "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione consectetur fuga molestias odio voluptatem vitae voluptates deleniti iure qui fugit, eveniet atque? Reprehenderit nobis ex aliquid, in nesciunt, explicabo fugiat.", + "price": "50$" + }, + { + "id": "event-2", + "image": "http://mybanket.com/sites/default/files/event-marketing2.jpg", + "name": "Second Event", + "description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ratione consectetur fuga molestias odio voluptatem vitae voluptates deleniti iure qui fugit, eveniet atque? Reprehenderit nobis ex aliquid, in nesciunt, explicabo fugiat.", + "price": "10$" + } + ]; + res.json(eventList); +}); + module.exports = router; diff --git a/src/js/app/app.js b/src/js/app/app.js index a9e08f3..d49e762 100644 --- a/src/js/app/app.js +++ b/src/js/app/app.js @@ -1,26 +1,35 @@ -(function () { - angular.module('eva', []) - .config(['$sceProvider', function ($sceProvider) { - $sceProvider.enabled(false); - }]) - .run(['$rootScope', - '$document', - '$timeout', - function ($rootScope, $document, $timeout) { +eventApp = angular.module('eva', ['ngRoute', 'ngResource']); +eventApp.config(['$routeProvider', '$locationProvider', function($routeProvide, $locationProvider){ + $locationProvider.html5Mode({ + enabled:true, + requireBase:false, + }) + $routeProvide + .when('/',{ + templateUrl:'/templates/index.html', + controller:'EventListCtrl', + controllerAs: "Events", + resolve: { + myData: ["httpDataLoader", function(httpDataLoader){ + return httpDataLoader.load(); + }] + } + }) + .when('/events/:eventId', { + templateUrl:'/templates/single-event.html', + controller:'EventDetailCtrl', + controllerAs: "EventDetail", + resolve: { + myData: ["httpDataLoader", function(httpDataLoader){ + return httpDataLoader.load(); + }] + } + }) + .otherwise({ + redirectTo: '/' + }); + } +]); - watchDigest(); - function watchDigest () { - var unregister = $rootScope.$watch(function(){ - console.log('digest-end'); - unregister(); - $timeout(function(){ - $rootScope.$emit('digest-end'); - watchDigest(); - },0,false); - }); - } - - }]); -})(); diff --git a/src/js/app/controllers/event.js b/src/js/app/controllers/event.js new file mode 100644 index 0000000..44fb288 --- /dev/null +++ b/src/js/app/controllers/event.js @@ -0,0 +1,14 @@ +eventApp.controller("EventListCtrl", ["$scope", "myData", function ($scope, myData) { + $scope.data = myData.data; +}]); + +eventApp.controller("EventDetailCtrl", ["$scope", "$routeParams", "myData", function ($scope, $routeParams, myData) { + $scope.eventId = $routeParams.eventId; + $scope.data = myData.data; + for(var i = 0; i < myData.data.length; i++) { + $scope.event = myData.data[i]; + if($scope.event.id === $routeParams.eventId) { + return $scope.event; + } + } +}]); \ No newline at end of file diff --git a/src/js/app/services/event.js b/src/js/app/services/event.js new file mode 100644 index 0000000..e0095aa --- /dev/null +++ b/src/js/app/services/event.js @@ -0,0 +1,5 @@ +eventApp.service("httpDataLoader", ["$http", function($http) { + this.load = function() { + return $http.get("/api/events-list"); + } +}]); \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 0000000..d927355 --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,7 @@ +
{{event.description}}
+ Price: {{event.price}} +