I've been searching for a solution to replicate this behavior in Typescript but haven't found one yet.
It's important to remember that TypeScript is essentially JavaScript. It seems like you may be referring to Angular2
(since the post is about Angular1).
Exploring Angular2
To achieve what you're looking for, you'll need to access the DOM element (which appears to be causing some confusion). In your controller, make sure to inject ElementRef
. For example:
@Inject(ElementRef) elementRef: ElementRef,
Once you have the element, you can navigate through it and perform any necessary DOM manipulation or manual actions.
Additional Resources
Documentation : https://angular.io/docs/js/latest/api/core/ElementRef-class.html
Illustrative Example
Check out this example :
import {Component, ElementRef} from 'angular2/core';
@Component({
selector:'display',
template:`
<input #myname (input) = "updateName(myname.value)"/>
<p> My name : {{myName}}</p>
`
})
class DisplayComponent implements OnInit {
constructor(public element: ElementRef) {
this.element.nativeElement // <- your direct element reference
}
ngOnInit() {
}
}