2

I'm new to all web and coding in general, not just angular. So sorry if this is obvious, how do I handle a large majority of templates that could all use the same controller?

My thinking was I could treat a folder of html files (my slides) as if they were in an array, and create two navigation buttons that could simply move back and forth through the array.

A way I've tried to accomplish this is as follows:

.when('/lesson1/slide/:slideCount', {

template : function($routeParams) {

return 'pages/lessons/lessons01/slide' + $routeParams.slideCount + '.html'

},

controller: 'lessonsCtrl'

})

But this just displays the string "pages/lessons/lessons01/slide1.html" at my ng-view instead of putting in the html found on in that file. I've also tried

.config(function ($routeProvider, $routeParams) ...

templateUrl: 'pages/lessons/lessons01/slide' + $routeParams.slideCount + '.html'

This one gives a blank ng-view at every .when, not just the specific one I'm trying to get my html slides to work on. Is there another way of doing this that works? The end goal to all this to create a more interactive powerpoint type presentation I could post on the web. Hope that makes sense.

Update:The content on the slides will be a couple images, a few blocks of text revealed on a time delay or click, and an audio clip. Eventually I'd like to add a way to record and play back audio within these slides too, but I'll cross that bridge when I get there.

3
  • depending on what the data in all those html files looks like (considering they could all use the same controller), you might try just moving the data into a json object. It would make things much simpler if that's possible Commented Aug 17, 2015 at 16:34
  • Perhaps, but I haven't done much with that yet. I'll look up more about json today on w3schools, etc. Updated question with slide contents. Commented Aug 17, 2015 at 16:45
  • @Dookie67 tell Mr. Johnny Test I say hi Commented Aug 17, 2015 at 16:46

1 Answer 1

2

You just have to pass a function to templateUrl instead of a string:

$routeProvider.when('/lesson1/slide/:slideCount', {
  templateUrl: function($routeParams) {
    return 'pages/lessons/lessons01/slide' + $routeParams.slideCount + '.html';
  },
  // ...
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.