Hi,
I've got a specifc problem. In the example below I want to load the feed of 
the first RSS (TechCrunch in this example) directly when the page load.
Now I have to click the link (ng-click) before it loads. 

I have fiddled around with setting the 
$scope.feedSrc="http://feeds.feedburner.com/TechCrunch"; in the js code, and 
then calling the function with $scope.loadFeed();
But have not got it to work.

Would really appreciate some help.

Example here.
http://codepen.io/anon/pen/rxOoNV


HTML
<head>
  <script 
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js";></script>
  <link rel="stylesheet" type="text/css" 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css";>
  <script type="text/javascript" 
src="https://www.google.com/jsapi";></script>
  <script 
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js";></script>
  <script 
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-resource.min.js";></script>
</head>

<div data-ng-controller="FeedCtrl" ng-app="RSSFeedApp">

  <p>
    <a href="#" 
ng-click="feedSrc='http://feeds.feedburner.com/TechCrunch';loadFeed($event);">TechCrunch</a>
 
|
    <a href="#" 
ng-click="feedSrc='http://rss.cnn.com/rss/cnn_topstories.rss';loadFeed($event);">CNN</a>
  </p>

  <ul class="unstyled">
    <li ng-repeat="feed in feeds | filter:filterText">
      <h5><a href="{{feed.link}}">{{feed.title}}</a></h5>
      <p class="date">{{feed.publishedDate | date : format : timezone}}</p>
    </li>
  </ul>

</div>

JS
var App = angular.module('RSSFeedApp', []);

App.controller("FeedCtrl", ['$scope', 'FeedService', function($scope, Feed) 
{

  $scope.loadFeed = function(e) {
    Feed.parseFeed($scope.feedSrc).then(function(res) {
      $scope.feeds = res.data.responseData.feed.entries;
    });

  }
}]);

App.factory('FeedService', ['$http', function($http) {
  return {
    parseFeed: function(url) {

      return 
$http.jsonp('//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=5&callback=JSON_CALLBACK&q='
 
+ encodeURIComponent(url));
    }
  }
}]);



-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to