Skip to content

Commit

Permalink
Merge pull request siddii#11 from nzalheart/master
Browse files Browse the repository at this point in the history
Fixed the dynamic binding of feed url
  • Loading branch information
siddii committed Jul 1, 2015
2 parents 58d27d6 + fa81901 commit 83f7ced
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/scripts/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,25 @@ angular.module('feeds-directives', []).directive('feed', ['feedService', '$compi
}
}
}

feedService.getFeeds($attrs.url, $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')

$attrs.observe('url', function(url){
feedService.getFeeds(url, $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')
});
});
}]
}
Expand Down

0 comments on commit 83f7ced

Please sign in to comment.