I'm trying to create a frontend with angularjs for an app that generates rss feeds. So i want to configure a route that will render the rss.
So the basic idea is, when a user goes to http://myserver/#/myTopic/rss the server should return the result of the following api call http://myserver/api/1/myTopic/rss
So I created my route as below.
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
// render rss feed
when('/:topic/rss', {
controller: 'rssCtrl'
});
}]);
And the rssCtrl is defined like this
var rssCtrl = function($scope, $location, $routeParams) {
// what to put in it??
};
app.controller('rssCtrl', rssCtrl);
I'm conceptually stuck on what to put in my controller, since I don't want the index.html to be rendered (my single page app) but the rss feed.
Any ideas? thoughts?
Regards
I don't think that this is possible. Angular is a client-side framework, i.e. it works by sending the JavaScript to the browser where it generates the HTML. You cannot assume that an RSS feed reader will interpret JavaScript, in fact most don't since it's considered a security risk. So you need to generate the RSS feed on the server-side.
The $location service allows you to change only the URL; it does not allow you to reload the page. When you need to change the URL and reload the page or navigate to a different page, please use a lower level API, $window.location.href. -- $location