get info of a slide and show it. Sanitize html from description field and add it to the scope
authorrougeronj
Mon, 23 Mar 2015 17:07:36 +0100
changeset 31 8d016c195d79
parent 30 d0d0a893401d
child 32 802ba9793507
get info of a slide and show it. Sanitize html from description field and add it to the scope
client/app/slides/slides.html
client/app/slides/slides_controller.js
--- a/client/app/slides/slides.html	Mon Mar 23 17:05:45 2015 +0100
+++ b/client/app/slides/slides.html	Mon Mar 23 17:07:36 2015 +0100
@@ -2,15 +2,15 @@
 <div class="carousel-holder row">
 	<div class="row">
 		<div class="col-md-6 col-md-offset-1">
-			<img ng-src="{{ slide.metas_dict.images }}" style="margin: auto;">
+			<img ng-src="{{ slide.details.firstImg }}" style="margin: auto;">
 		</div>
 		<div class="carousel-caption col-md-4">
 			<slide-editor index="{{$index}}"></slide-editor>
 			<hr />
 			<h4 class="original-text">{{ slide.metas_dict.name }}</h4>
 			<p class="original-text">{{ slide.metas_dict.description }}</p>
-			<p><small><strong>Titre&nbsp;:</strong> {{ slide.details.title }}</small></p>
-			<p><small><strong>Description&nbsp;:</strong> {{ slide.details.description }}</small></p>
+			<p><strong>Titre&nbsp;:</strong><small>{{ slide.details.title }}</small></p>
+			<p><strong>Description&nbsp;:</strong><small ng-bind-html="slide.details.description"></small></p>
 		</div>
 	</div>
 </div>
--- a/client/app/slides/slides_controller.js	Mon Mar 23 17:05:45 2015 +0100
+++ b/client/app/slides/slides_controller.js	Mon Mar 23 17:07:36 2015 +0100
@@ -1,19 +1,18 @@
 (function(){
-  'use strict';
+	'use strict';
 
-  angular.module('ammicoSlides',['ngResource', 'ngRoute'])
-    .config(function ($routeProvider) {
-      $routeProvider
-        .when('/', {
-          templateUrl: 'slides/slides.html',
-          controller: 'slidesCtrl'
-        });
-    })
-    .controller('slidesCtrl', function($scope, booksModel, $routeParams){
-    	console.log(booksModel.slides[$routeParams.idSlide]);
-    	$scope.slide = booksModel.slides[$routeParams.idSlide];
-    })
-  	.controller('slideEditCtrl', function(){
-  	});
+	angular.module('ammicoSlides',['ngResource', 'ngRoute'])
+	.controller('slidesCtrl', function($scope, $routeParams, searchApi, $sce){
+		
+		$scope.slide = searchApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
+			data.details.description =  $sce.trustAsHtml(data.details.description);
+		});
+		
+		console.log($routeParams.idSlide);
+		console.log($scope);
+		//$scope.slide = booksModel.slides[$routeParams.idSlide];
+	})
+	.controller('slideEditCtrl', function(){
+	});
 
 })();