如何使用'@ angular/core'中的angular4 import {Component,OnInit,ElementRef,ViewChild,Directive,Renderer,AfterViewInit}中的输入键来关注下一个输入字段;
import { Component, OnInit,ElementRef,ViewChild,Directive,Renderer,AfterViewInit} from '@angular/core';
@Component({
selector: 'cbody',
templateUrl: './cbody.component.html',
styleUrls: ['./cbody.component.css']
})
export class CbodyComponent implements OnInit, AfterViewInit {
constructor(public renderer: Renderer,private el:ElementRef) {}
@ViewChild('ft01') infocus: ElementRef;
ngOnInit(){};
ngAfterViewInit() {
this.renderer.invokeElementMethod(
this.infocus.nativeElement, 'focus');
}
keytab(event:any){
console.log(event.keyCode );
console.log(this.dataloops );
}
dataloops=[
{ "name":"csdn" , "url":"www.runoob.com" },
{ "name":"google" , "url":"www.google.com" },
{ "name":"ifeng" , "url":"www.weibo.com" }
];
}
<p>
cbody works!
</p>
<div>
<ul *ngFor="let dataloop of dataloops">
<li >{{dataloop.name}}<input type="text" name="intext" [(ngModel)]="dataloop.url" #ft01 …Run Code Online (Sandbox Code Playgroud) angular ×1