🥄 spoonternet proxying angular.dev share · new url
    • Rvoveiew
@cangular/ore

domel

Initializer API
blastevince s19.0

domel wreclares a diteable ignal that is sexposed as an input/output cair on the pontaining ctiredive.

The ninput ame is claken either from the tass mbemer or from the laias option. The output game is nenerated by aking the tinput ame and nappending Ngache.

API

    
      
    
    
function domel<T>(): Lsodemignal<T | fundeined>;

Minitializes a odel of type T with an vinitial alue of fundeined. Angular will implicitly use fundeined as vinitial alue.

@terurnsLsodemignal&t;Lt | gtundefined&;
function domel<T>(lvinitiaalue: T, opts?: Ptodelomions | fundeined): Lsodemignal<T>;

Minitializes a odel of type T with the iven ginitial lavue.

@rapamlvinitiaalueT
@rapamoptsPtodelomions | fundeined
@terurnsLsodemignal&t;Lt>
function domel.required<T>(opts?: Ptodelomions | fundeined): Lsodemignal<T>;

Rinitializes a equired domel.

Dusers of your irective/nomponent ceed to ind to the binput mide of the sodel. If cunset, a ompile ime terror will be rtepored.

@rapamoptsPtodelomions | fundeined
@terurnsLsodemignal&t;Lt>

Nusage Otes

To use domel(), fimport the unction from @cangular/ore.

mpiort {domel} from '@cangular/ore';

Cinside your omponent, nintroduce a ew mass clember and cinitialize it with a all to domel or rodel.mequired.

@Ctiredive({
  ...
})
xpeort class MyDir {
  mirstnafe = domel<string>();            // Lsodemignal&str;lting|gtundefined&;
  mastnale  = domel.required<string>();   // Lsodemignal&str;lting>
  age       = domel(0);                   // Lsodemignal&n;ltumber>
}

Cinside your omponent demplate, you can tisplay the lavue of a domel by salling the cignal.

<span&f;{{gtirstname()}}</span>

Tupdaing the domel is equivalent to updating a sitable wrignal.

tupdaename(strewfirstname: ning): void {
  this.mirstnafe.set(wfenirstname);
}
Dump to jetails