Skip to content
  • Works
  • Services
  • About
  • Blog
  • Contact

Start free trial

We bring together everything that’s required to build websites. Reach more customers, save time and money, and boost sales.

Edit Content

    • Facebook
    • Instagram
    • Twitter
    Purchase Theme
    AngularJS, JS

    Making a Quick RSS Feed Reader using AngularJS

    February 20, 2013 M. Mahbubur Rahman No comments yet

    Since AngularJS is the default JavaScript Framework for Front End Application at iVive, we decided to post some angularJS articles from now on. At first, we’re coming up with a nifty minimal RSS Feed Reader with few lines of code.

    Demo View It Online
    Download Source Files

    You clicked the demo button, didn’t you ? This idea of showing the demo + source at the top of page was from Envato sites which everyone likes. People feel more interested this way.

    Anyways, let’s look at what we did. We used one of the preferred angular code conventions, used $http and a factory as you can see below.

    [cc lang=”javascript”]

    ‘use strict’;

    var App = angular.module(‘RSSFeedApp’, []);

    App.controller(“FeedCtrl”, [‘$scope’, ‘FeedService’, function ($scope, Feed) {
    $scope.loadButonText = “Load”;
    $scope.loadFeed = function (e) {
    Feed.parseFeed($scope.feedSrc).then(function (res) {
    $scope.loadButonText = angular.element(e.target).text();
    $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=50&callback=JSON_CALLBACK&q=’ + encodeURIComponent(url));
    }
    }
    }]);

    [/cc]

    We have this one Controller FeedCtrl which gets invoked from the template


    For convenience we have pre-filled some feed source and put it with Bootstrap dropdown menu.

    [cc lang=”html”]

    • CNN
    • Hacker News
    • Mashable
    • Huffington Post
    • TechCrunch

    [/cc]

    Using ng-click on the dropdown links we point populate the feed source url to the input field called feedSrc and call the loadFeed method within the FeedCtrl Controller. Since the source of the feeds are on a different domain, we had to use JSONP. $http provider has a shortcut for this $http.jsonp(url,config) – which returns a promise. We wrapped this jsonp call within a service so that in future we can change it if we want (with $resource may be ?).

    Ow, forgot to mention, as you might probably know that RSS feeds are basically XML but we want JSON right ? Google fortunately has an API service which will turn our XML feed into JSON. If we look at the parseFeed method, we are giving the feed url to Google and send us with a JSON. Don’t forget the callback thing, in JSONP calls.

    Ok, now that the Feed service is giving us the JSON with a promise callback, we’d simply assign a scope variable to iterate through the results. We have used it like $scope.feeds=res.data.responseData.feed.entries;. And in the template part, we’re using an ng-repeat directive to loop through the object and come up with the view.

    [cc lang=”html”]

    • {{feed.title}}

      {{feed.contentSnippet}}

      {{feed.publishedDate}}

    [/cc]

    You might notice that we have filter too which can filter results of the fetched feed using the second textbox on top of the page. Passing a model as an argument to the filter just filters it. YES! it’s that simple. And if you look at closely, it only shows up when we have feeds using the magical ng-show thing.

    Attaching a screenshot here of how it appears.

    angular-rss-feed-reader

    In coming articles, we might want to make it a little more rich with some other stuffs. Hope you like is. Send us any questions you might have.

    • angularjs
    • javascript
    M. Mahbubur Rahman

    Post navigation

    Previous
    Next

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Search

    Categories

    • Agency (1)
    • AngularJS (5)
    • blog (7)
    • Branding (2)
    • Competitive Marketing Analysis (1)
    • Design (4)
    • Development (10)
    • JS (3)
    • Keywords Analysis (1)
    • Keywords Research (1)
    • Latest News (3)
    • Life at iViveLabs (2)
    • Lifestyle (1)
    • Marketing (6)
    • Onpage Optimization (1)
    • Photography (3)
    • SEO (6)
    • Travel (3)
    • Web development (2)

    Tags

    angularjs api Apple Mac Pro Desktop badmintion beautyful flowers of darjeeling beauty of darjeeling competitive audit report competitive marketing analysis filters flowers of darjeeling get more conversion get more traffic impression from pinterest internet marketing analysis report ivivelabs javascript javscript journey keywords research and analysis link assistant maowa Mawa more conversion more traffic natural beauty darjeeling New Pinterest Web Analytics organic keywords organig keywords research pagination Pagination In AngularJS panam nagar Pin My Post pinterest impression SEO seo audit report Show More Pagination In angularJS sonargaon stories The Future Of The Pro Desktop Track Pinning Activity travel typekit weather wordpress wp-cli

    Related posts

    AngularJS, blog, Web development

    AngularJS weather forecast Widget [Part 1]

    March 30, 2014 M. Mahbubur Rahman No comments yet

    Ok, we’re going to create this today.   Demo View It Online Download Source Files   And we’re going to achieve this using AngularJS Twitter Bootstrap 3 Open Weather Map API CSS3 Of course we can make similar things using only jQuery but let’s make something cool and learn some stuff on the way.   […]

    AngularJS, JS

    Pagination in AngularJS for Typekit API – Show More Pagination in AngularJS

    March 4, 2013 M. Mahbubur Rahman No comments yet

    Pagination in web applications is a very common phenomenon and frequently used to split large result set into pages. The evolution of pagination with creativity has brought us from [1,2,3] to automatic pagination (like you see on google images). Naturally the number based pagination is becoming less and less common these days. We are seeing […]

    AngularJS, JS

    How to make a custom filter in AngularJS ?

    February 26, 2013 M. Mahbubur Rahman No comments yet

    AngularJS is a great open-source JavaScript Framework maintained by Google. This framework has got some compelling features. Filters is one of them for formatting the data in users locale. So we’ve decided to write a simple custom angular filter to sort clients table filtered by company. Demo View It Online Download Source Files At first, […]

    Our beautiful designs open the door to a realm of limitless possibilities, where imagination knows no bounds.

    Features
    • Page builder
    • Theme options
    • Theme builder
    • Template library
    Resources
    • Support center
    • Documentation
    • Community
    • Hosting
    Follow us
    • Behance
    • Dribbble
    • Facebook
    • Instagram
    Get in touch
    • hello@company.com

    © Sierra WordPress Theme. All Rights Reserved.

    • Terms & Conditions
    • Privacy Policy