Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for binding in url attribute #7

Open
tgrant59 opened this issue Mar 18, 2015 · 3 comments
Open

Support for binding in url attribute #7

tgrant59 opened this issue Mar 18, 2015 · 3 comments

Comments

@tgrant59
Copy link

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
Copy link

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
Copy link
Owner

siddii commented Jun 15, 2015

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

This was referenced Nov 3, 2015
@jakubkrizkabackup
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants