Skip to content

Simple app to demonstrate calling youtube api from an angular app

Notifications You must be signed in to change notification settings

mickyginger/angular-youtube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-youtube

Simple app to demonstrate integrating the YouTube Data API into an Angular app.

Initializing the Google Client API

The client api requires a callback parameter which calls a function in app.js, which in turn calls a function in the MainController which loads the youtube api and does a bit of housekeeping.

This seems to be Google preferred method: AngularJS + Cloud Endpoints -- A Recipe for Building Modern Web Applications

Youtube API service

A simple wrapper for the youtube search function, using $q to wrap the call in a promise.

$scope.$apply vs $timeout vs $scope.$evalAsync

When using external APIs, Angular is unaware when properties on the controller have been updated. $scope.$apply forces Angular to update its view, however, I was getting an error $digest already in progress, so I changed the call to a $timeout([function], 0).

After reading this article: AngularJS: $apply vs $timeout vs $digest vs $evalAsync I changed it to $scope.$evalAsync(), which seems a more appropriate method.

Still not 100% sure what the best approach is for this, so welcome any input.

About

Simple app to demonstrate calling youtube api from an angular app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published