Update the injector static variable to contain all injected values.

In Angular.js, values are injected into service in one of two ways:

1) Inline (by name).
2) By a static injector variable.

The TypeScript generator uses the 2nd method. This method requires you
to explicitly enumerate all the values you would like to have injected.
If you fail to inject a value the Angular DI system will simply pass you
`undefined`. The constructor is expecting 3 values to be passed (the
final being basePath) but the injector static only defines 2 values.
This results in basePath always being undefined no matter what you
define it to be.

This change updates the injector variable to handle that properly.
This commit is contained in:
Andrew Z Allen 2016-05-09 22:46:50 -06:00
parent e17710fc72
commit 51ad775aee
4 changed files with 4 additions and 4 deletions

View File

@ -15,7 +15,7 @@ namespace {{package}} {
protected basePath = '{{basePath}}';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer'];
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) {

View File

@ -9,7 +9,7 @@ namespace API.Client {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer'];
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) {

View File

@ -9,7 +9,7 @@ namespace API.Client {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer'];
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) {

View File

@ -9,7 +9,7 @@ namespace API.Client {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer'];
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath) {