In this video Iftach Bar shows how you can inject different Angular services in the console while debugging the application.
- [Instructor] The last step is a bit off course.…But it is another tool that I find useful…when debugging Angular web apps.…Sometimes you don't just want to get a scope…in the console, but you might want…to get some service or factory…you exposed in your Angular app.…There is an easier way to do that.…Since our application doesn't have any services,…I'll show you how I inject the built-in $http service.…The same method can be used…to inject services you have written…and not only for built-in Angular services.…
So I'll go in the console, and I'll try to get…some Angular element.…It doesn't matter which element I'm going to get.…Usually, using document.body will be the safest choice.…So write angular.elementdocument.body.…I'm going to use a function called Injector.…On this Injector, I'll use the Get function…and I'm going to give it a string…with the name of the service I want to inject.…I'll save it in a variable.…
In one simple line in the console,…I can now start playing with the service,…test it, run some of its code.…
This advanced AngularJS course helps you explore the connected worlds of $scope and the digest cycle. Instructor Iftach Bar explains scope and inheritance, goes behind the scenes of the digest loop, and teaches both manual and automatic data binding approaches. Plus, learn how to integrate external libraries, diagnose performance issues, and debug your applications.
- $scope and controllers
- $scope built-in variables and methods
- $scope prototype inheritance
- Manual data binding with $scope.$watch
- The digest loop
- Get the $scope in the console
- Forcing $digest
Skill Level Advanced
AngularJS 1: Building a Data-Driven Appwith Ray Villalobos2h 15m Intermediate
1. Scope Basics
2. Manual Data Bindings
3. The Digest Loop
4. Tips for Debugging Angular in the Console
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.