The factory method, used for creating a directive, gets invoked when the compiler matches the directive for the first time. This function can be invoked by $injector.invoke.

Syntax: module.factory( 'factoryName', function );

When you declare factoryName as an injectable argument, you will get the value which will be returned by invoking the function reference passed to the module.factory.

BY Best Interview Question ON 01 Apr 2020