siddii / angular-feeds

AngularJS module for Atom, RSS & Media feeds
http://siddii.github.io/angular-feeds/app/
MIT License
59 stars 57 forks source link

Support for binding in url attribute #7

Open tgrant59 opened 9 years ago

tgrant59 commented 9 years ago

I am trying to bind a variable as part of the url parameter passed to the feed directive, but it refuses to bind.

For example, calling this doesnt work:

<feed url="http://{{restOfUrl}}.rss"></feed>

but static urls do. Any thoughts on how to implement this functionality? Using ng-attr-url doesn't work either, so beyond that I'm out of ideas.

Love the drop-in functionality of the directive btw.

nzalheart commented 9 years ago

Hi,

I had the same requirement but the module didn't support the feature.

So I had to make a tweak in angular-feed.js that I included in my project. In line 39, $attrs.url had to be replaced with $attrs.$observe('url', function(value){})...

With this modification on line 39, my code looks like.

  $attrs.$observe('url', function(value){
        feedService.getFeeds(value, $attrs.count).then(function(feedsObj) {
            if ($attrs.templateUrl) {
                $http.get($attrs.templateUrl, {cache: $templateCache}).success(function(templateHtml) {
                    renderTemplate(templateHtml, feedsObj);
                });
            }
            else {
                renderTemplate($templateCache.get('feed-list.html'), feedsObj);
            }
        }, function(error) {
            console.error('Error loading feed ', error);
            $scope.error = error;
            renderTemplate($templateCache.get('feed-list.html'));
        }).finally(function() {
            $element.find('.spinner').slideUp();
            $scope.$evalAsync('finishedLoading = true')
        });
  });

I wonder if the owner of this library can update this.

siddii commented 9 years ago

@nzalheart - Can you please create a PR? I can push this change to master.

jakubkrizkabackup commented 8 years ago

very thank you for this edit :) I love you man ...