This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Factory that doesn't return an object silently inject null #4575
Closed
Description
Factory that return null instead of an object silently inject null object:
Example:
http://plnkr.co/edit/SJM7yZafOxV0Vu6peLQL?p=preview
var app = angular.module('plunker', []);
app.factory('api', function() {
var self = this;
// no returns...
// return self;
});
app.controller('MainCtrl', function($scope, api) {
if(api) {
$scope.name = 'api injected';
} else {
$scope.name = 'api not injected';
}
});
ACTUAL: no errors on console, $scope.name set to api not injected
EXPECTED: some sort of console warning with a useful error for newbies