I have a question that seems simple, but I can't seem to find the answer anywhere.
My goal is to load JSON data from my server into the client using AngularJS.
How can I display all three slides in my view with AngularJS? Currently, with this code, only one slide is being displayed.
VIEW:
<div ng-app="app">
<div ng-controller="CarouselDemoCtrl" id="slides_control">
<carousel interval="myInterval">
<slide ng-repeat="slide in slides" active="slide.active">
<div class="slide"><h2 class="slide-text">{{slide.Carousel[0]}}</h2></div>
</slide>
</carousel>
</div>
</div>
CONTROLLER:
angular.module('app')
.controller('CarouselDemoCtrl', function($scope, dataService) {
$scope.addSlide = function() {
var newSlide = {"Carousel": $scope.values}
$scope.slides.push(newSlide);
};
$scope.myInterval = 3000;
dataService.getSlides(function(response) {
console.log(response.data);
$scope.slides = response.data;
});
})
SERVICE:
angular.module('app')
.service('dataService', function($http) {
this.getSlides = function(callback) {
$http.get('json/be-creative.json')
.then(callback)
}
});
JSON:
[
{"AboutUs": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularized in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."},
{"Carousel": ["Slide 1", "Slide 2", "Slide 3"]}
]