Ng-bind into ionic

im using latest ionic and angular. im a bit of a novice programmer, so please bear with my codes.

export class AppComponent{
	sample1 = 'hello';
	drawmap():void{
		function _fname1():void{
			var var1 = "a";
		}
	}
	other():void{
		function _imtired():void{
		}
	}
}

here’s my dillema. I know i can use variable sample1 in AppComponent into ionic with ngbinding {{ sample1 }}.

but how do you ngbind var1 INSIDE function _fname1 INSIDE drawmap() (at this point im still not so sure as to what drawmap is. not sure if it’s a “normal” function or is it a constructor). I dont know how to use the value of var1 and also alter it’s value in other() or _imtired() inside other(). please, i’m begging for help.

This isn’t a good idea. Take a few weeks, and learn the basics of HTML, SASS, TypeScript, and Javascript ES6. Come back to Ionic after that.

It’s not clear what you want to do here, why are you declaring functions inside the methods? In the code the functions aren’t doing anything anyway.

Still, the issue is you want to maintain scope.

export class AppComponent{
	sample1 = 'hello';
	drawmap():void{
            console.log(this.sample1); // hello
		let fname1 = ():void => {
            console.log(this.sample1); // hello
			var var1 = "a";
		}
	}
}

Your life will become easier if you never type the word function or var.