Skip to content
Snippets Groups Projects
Commit cba982cd authored by francois.grand's avatar francois.grand
Browse files

déplacement du provider de ParamService dans le composant racine...

déplacement du provider de ParamService dans le composant racine (AppComponent) pour n'avoir qu'une seule instance de ParamService
parent d96ed6a1
No related branches found
No related tags found
No related merge requests found
......@@ -4,5 +4,6 @@
"routes": {
"/node_modules": "node_modules"
}
}
},
"browser": "chromium-browser"
}
import { Component } from '@angular/core';
import { ParamService } from './param-service/param.service';
@Component({
selector: 'nghyd-app',
template: `
<h1>{{title}}</h1>
<param-input symbol="Q"></param-input>
<param-input symbol="Ks"></param-input>
<param-input symbol="Q"></param-input>
`,
providers: [ParamService]
})
export class AppComponent {
title = "Calculette hydro";
......
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var core_1 = require("@angular/core");
var param_service_1 = require("../param-service/param.service");
var ParamInputComponent = (function () {
function ParamInputComponent(paramService) {
this.paramService = paramService;
}
ParamInputComponent.prototype.ngOnInit = function () {
this._paramDef = this.paramService.getParameter(this._paramSymbol);
};
return ParamInputComponent;
}());
__decorate([
core_1.Input('symbol'),
__metadata("design:type", String)
], ParamInputComponent.prototype, "_paramSymbol", void 0);
ParamInputComponent = __decorate([
core_1.Component({
selector: "param-input[symbol]",
templateUrl: "./param-input.component.html",
providers: [param_service_1.ParamService]
}),
__metadata("design:paramtypes", [param_service_1.ParamService])
], ParamInputComponent);
exports.ParamInputComponent = ParamInputComponent;
//# sourceMappingURL=param-input.component.js.map
\ No newline at end of file
{"version":3,"file":"param-input.component.js","sourceRoot":"","sources":["param-input.component.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,sCAAyD;AAIzD,gEAA8D;AAO9D,IAAa,mBAAmB;IAQ5B,6BAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAI,CAAC;IAEnD,sCAAQ,GAAR;QACI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACvE,CAAC;IACL,0BAAC;AAAD,CAAC,AAbD,IAaC;AAToB;IAAhB,YAAK,CAAC,QAAQ,CAAC;;yDAAsB;AAJ7B,mBAAmB;IAL/B,gBAAS,CAAC;QACP,QAAQ,EAAE,qBAAqB;QAC/B,WAAW,EAAE,8BAA8B;QAC3C,SAAS,EAAE,CAAC,4BAAY,CAAC;KAC5B,CAAC;qCASoC,4BAAY;GARrC,mBAAmB,CAa/B;AAbY,kDAAmB"}
\ No newline at end of file
......@@ -7,13 +7,12 @@ import { ParamService } from '../param-service/param.service';
@Component({
selector: "param-input[symbol]",
templateUrl: "./param-input.component.html",
providers: [ParamService]
})
export class ParamInputComponent implements OnInit {
/**
* Parameter symbol (Q, Ks, B, ...)
* Parameter symbol (Q, Ks, B, ...) attribute
*/
@Input('symbol') _paramSymbol: string;
@Input('symbol') private _paramSymbol: string;
private _paramDef: ParamDefinition;
......
"use strict";
var jalhyd_1 = require("jalhyd");
var ParamService = (function () {
function ParamService() {
this._params = [new jalhyd_1.ParamDefinition('Q', jalhyd_1.ParamDomainValue.POS_NULL, 0),
new jalhyd_1.ParamDefinition('Ks', jalhyd_1.ParamDomainValue.POS, 1)];
}
ParamService.prototype.getParameter = function (s) {
for (var _i = 0, _a = this._params; _i < _a.length; _i++) {
var p = _a[_i];
if (p.symbol == s)
return p;
}
return undefined;
};
return ParamService;
}());
exports.ParamService = ParamService;
//# sourceMappingURL=param.service.js.map
\ No newline at end of file
{"version":3,"file":"param.service.js","sourceRoot":"","sources":["param.service.ts"],"names":[],"mappings":";AAAA,iCAA2D;AAE3D;IAGI;QACI,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,wBAAe,CAAC,GAAG,EAAE,yBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;YACtE,IAAI,wBAAe,CAAC,IAAI,EAAE,yBAAgB,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,mCAAY,GAAZ,UAAa,CAAS;QAClB,GAAG,CAAC,CAAU,UAAY,EAAZ,KAAA,IAAI,CAAC,OAAO,EAAZ,cAAY,EAAZ,IAAY;YAArB,IAAI,CAAC,SAAA;YACN,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;gBACd,MAAM,CAAC,CAAC,CAAC;SAChB;QAED,MAAM,CAAC,SAAS,CAAC;IACrB,CAAC;IACL,mBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,oCAAY"}
\ No newline at end of file
import { ParamDefinition, ParamDomainValue } from 'jalhyd';
import { ParamDefinition, ParamDomainValue, ParamCalculability } from 'jalhyd';
export class ParamService {
private _params: ParamDefinition[];
......@@ -6,6 +6,8 @@ export class ParamService {
constructor() {
this._params = [new ParamDefinition('Q', ParamDomainValue.POS_NULL, 0),
new ParamDefinition('Ks', ParamDomainValue.POS, 1)];
for (let p of this._params)
p.calculability = ParamCalculability.DICHO;
}
getParameter(s: string): ParamDefinition {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment