import { bootstrapApplication } from '@angular/platform-browser';
import { Component, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-root',
imports: [FormsModule],
template: `
{{title}}
Value of the X Property X: {{x().Value}}
`,
styles: ['html { line-height: 1.15;} input{border: 0.1em solid lightgreen;}'],
})
export class AppComponent {
protected title = 'How to update an Immutable Signal Object which is itsels a AppComponent Proberty? ';
readonly x = signal ({
variableName: 'X',
Value: 0,
unit: ''
});
upDateMethod(){
this.x.update(f => f.Value= 1234 ) // Does not work
}
}
interface IVariableBuilder {
readonly variableName: string; // to get information, which variable was changed by
readonly Value: number,
readonly unit: string;
}
bootstrapApplication(AppComponent);
Я борюсь с простым простым объектом, который сам по себе является свойством AppComponent . Этот объект «x» обернут как записываемый сигнал.[code]import { bootstrapApplication } from '@angular/platform-browser'; import { Component, signal } from '@angular/core'; import { FormsModule } from '@angular/forms';
styles: ['html { line-height: 1.15;} input{border: 0.1em solid lightgreen;}'], }) export class AppComponent { protected title = 'How to update an Immutable Signal Object which is itsels a AppComponent Proberty? ';
readonly x = signal ({ variableName: 'X', Value: 0, unit: '' });
upDateMethod(){ this.x.update(f => f.Value= 1234 ) // Does not work } }
interface IVariableBuilder { readonly variableName: string; // to get information, which variable was changed by readonly Value: number, readonly unit: string; }
bootstrapApplication(AppComponent); [/code] также см. Mystackbiltzcode