From c521f2670b7a56a832410e90b5617543b6c4315d Mon Sep 17 00:00:00 2001 From: Sebastian Seedorf Date: Tue, 29 Mar 2016 17:51:00 +0200 Subject: [PATCH] =?UTF-8?q?AngularJS-Service=20implementiert;=20Reissorte?= =?UTF-8?q?=20des=20Tages=20wird=20per=20http=20=C3=BCber=20angular=20nach?= =?UTF-8?q?geladen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.js | 4 ++++ public/css/style.css | 4 ++++ public/js/angular-init.js | 12 ++++++++++++ views/index.jade | 1 + 4 files changed, 21 insertions(+) diff --git a/main.js b/main.js index 4ac0172..4cb7106 100644 --- a/main.js +++ b/main.js @@ -214,6 +214,10 @@ app.post('/login', function(req, res) { }); }); +app.get('/api/specialOffer.json', function(req, res) { + res.json({ rice: "Neuer Waldreis" }); +}); + var server = app.listen(3000, function() { var host = server.address().address; var port = server.address().port; diff --git a/public/css/style.css b/public/css/style.css index 2ff735d..1ad0c46 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -88,6 +88,10 @@ textarea { margin-right: auto; } +[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { + display: none !important; +} + /* Login menu */ #loginDropdown { diff --git a/public/js/angular-init.js b/public/js/angular-init.js index 03c7546..58b9517 100644 --- a/public/js/angular-init.js +++ b/public/js/angular-init.js @@ -1,4 +1,16 @@ var app = angular.module('myApp', []); + +app.controller("indexController", function ($scope, specialService) { + $scope.rice = "Hello World"; + specialService.success(function(data) { + $scope.rice = data.rice; + }); +}); + +app.factory("specialService", function ($http) { + return $http.get('/api/specialOffer.json'); +}); + app.directive('rrMap', function() { return { restrict: 'A', diff --git a/views/index.jade b/views/index.jade index 693243b..a5770b2 100644 --- a/views/index.jade +++ b/views/index.jade @@ -47,6 +47,7 @@ block content .col-md-6.graygray +img-responsive-center("/bin/image/rice-world.png","Welt voller Reis") .col-md-6.orange Wir bieten Ihnen Reis aus aller Welt. Wählen Sie zwischen 52 verschiedenen Sorten oder lassen Sie sich durch die perfekte Wahl des Chefkochs überraschen. + p.ng-cloak(data-ng-controller="indexController") Die heutige Empfehlung unseres Chefkochs ist "{{rice}}". Alle Gerichte, die mit dieser Reissorte bestellt werden, sind um 1€ vergünstigt! .row .col-md-6.graygray.hidden-md.hidden-lg +img-responsive-center("/bin/image/vegetables.png","Gemüse")