hi attempting use ngmodeled variable globally.
so far have following code snippet.
homepage.html
<ion-input type="text" value="" [(ngmodel)]="databaseid">
homepage.ts
public databaseid;
these functions work , when attempt print ngmodeled data home.ts class prints has been entered user. not sure how call databaseid class. have tried setting databaseid global (globals static , therefor not work).
could possibly explain way may access variable different class?
some possible thoughts had dependency injection , using providers. i'm not sure best way so.
the best way share variable between different components/directives use service. can bind ngmodel directly service, , access service multiple components.
service:
@injectable() export class myservice { databaseid: string; constructor() { this.databaseid = "1234"; } }
component:
export class mycomponent { constructor(private myservice: myservice) { } }
html:
<ion-input type="text" value="" [(ngmodel)]="myservice.databaseid">
services tutorial: https://angular.io/docs/ts/latest/tutorial/toh-pt4.html
dependency injection: https://angular.io/docs/ts/latest/cookbook/dependency-injection.html
Blazor is a recently released single-page app framework for building interactive client-side web apps with .NET. It uses open web standards without plugins or code transpilation and works with all modern web browsers. If you are a freelance net full stack developer, you can get more relevant projects on Eiliana.com, where top clients regularly post IT development projects.
ReplyDelete