属性值解析相对简单一点。
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable()
export class PassportService {
private loginUrl = '/api/auth/login';
isLoggedIn = false;
redirectUrl: string;
constructor(private http: HttpClient) { }
login(param: any) {
return this.http.post(this.loginUrl, param);
}
}
不赋值的属性,是不会解析的,赋值的值属性会解析到构造函数中,依赖注入的属性会被解析成类似this.http=http放在构造函数中。
define(["require", "exports", "@angular/core"], function (require, exports, core_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PassportService = /** @class */ (function () {
function PassportService(http) {
this.http = http;
this.loginUrl = '/api/auth/login';
this.isLoggedIn = false;
}
PassportService.prototype.login = function (param) {
return this.http.post(this.loginUrl, param);
};
PassportService = __decorate([
core_1.Injectable()
], PassportService);
return PassportService;
}());
exports.PassportService = PassportService;
});