angular-embedly icon indicating copy to clipboard operation
angular-embedly copied to clipboard

Create a more detailed documentation

Open brasileirorodrigo opened this issue 10 years ago • 4 comments

I am new to AngularJs development, and it really helps when there's a more detailed documentation (e.g.: explaining how to use the service to extract information).

brasileirorodrigo avatar Feb 26 '15 22:02 brasileirorodrigo

Please provide a more detailed description, it's hard to understand what exactly should I improve.....

Urigo avatar Feb 27 '15 11:02 Urigo

Angular-embedly has been great for embedding videos/photos, but let's say I am just trying to get a 'title', or the 'thumbnail_url' from a given URL, or the 'html' (to post it somewhere). I believe I should use 'embedlyService' to do that, right? The documentation doesn't show how to do it, I've been trying to figure it out but couldn't make it yet.

brasileirorodrigo avatar Feb 27 '15 16:02 brasileirorodrigo

@brasileirorodrigo have you looked at the embedly documentation? I don't want to create duplicates..

Urigo avatar Feb 27 '15 21:02 Urigo

@Urigo, I did (and also I have checked oEmbed's docs). The thing is not really about their documentation . It is quite actually about how to obtain the different parts of the .json file through Angular-Embedly. I have gotten to embed the title on the directive (by making some changes in the switch statement and some other places):

...
scope.embedTitle = data.data.title;
...

But it is not an embedding issue, it is more of an extracting issue. I believe the part of the code that may solve my issue is this (embedlyService):

            this.extract = function(inputUrl) {
                var escapedUrl = encodeURI(inputUrl);
                var embedlyRequest = getProtocol + '://api.embed.ly/1/extract?key=' + key + '&url=' +  escapedUrl;
                return $http({method: 'GET', url: embedlyRequest});
            };

I have been trying to access it from the controller.js, in many different ways, for example:

embedlyModule.controller('embedCtrl', ['$scope','$http','embedlyService', function($scope, $http, embedlyService) {
    $scope.urlToSearch = 'https://www.youtube.com/watch?v=U9PlYbmEWOk';
    console.log(embedlyService.extract('$scope.urlToSearch'));
}]);

But it never works. I do really believe that solving such problem is super-easy, but it is quite difficult for a beginner, as the module.provider is a sort of a function:

(function (module) {
    module.provider('embedlyService', function () {

And working with these kinds of providers started with a function is not covered on any tutorial I found on the web that teaches how to deal with services from the controller.

I hope I haven't been too redundant or confusing.. Thanks!

brasileirorodrigo avatar Feb 27 '15 23:02 brasileirorodrigo