我在Angular中使用TypeScript。
服务是:
- name : Create Install schtask
raw : "schtasks /create /tn \"SQLInstaller\" /tr C:\\SQL\\InstallSQLwithConfigIni.cmd /sd 01/01/1901 /ST 00:00 /sc ONCE /ru {{ansible_user}} /rp {{ansible_password}} /RL HIGHEST"
- name : Run Install schtask now
raw : "schtasks /run /tn \"SQLInstaller\""
问题是当我尝试在这样的组件中使用此服务时:
@Injectable()
export class AuthenticationService {
public localStorageService: LocalStorageService;
constructor(private http: Http, private credentials: Credentials, public apiUrl: ApiUrls, localStorageService: LocalStorageService) {
this.localStorageService = localStorageService;
}
}
当我尝试在组件中注入时,需要指定构造函数export class LoginComponent implements OnInit {
constructor(private fb: FormBuilder,
private authenticationService: AuthenticationService) {
}
}
。这不方便。
如何改进此代码?
我试图制作Fabric:
AuthenticationService
但它在第public authenticationFactory: AuthenticationService;
this.authenticationFactory = (http: Http, credential: Credentials, apiUrl: ApiUrls, localStorage: LocalStorageService) => {
return new AuthenticationService(http, credential, apiUrl, localStorage);
};
行