我正在制作分页组件。这是代码:
import {Component,OnInit,Input,Output,EventEmitter,OnChanges} from '@angular/core'
@Component({
selector:"pagination",
templateUrl:"pagination.component.html"
})
export class Pagination implements OnChanges{
@Input()
numOfPages:number;
@Output()
onPageClicked:EventEmitter<number>=new EventEmitter<number>();
pages:number[];
constructor(){
var a=<any>Array(this.numOfPages).keys();
this.pages= a;
}
ngOnChanges(){
debugger;
var a=<any>Array(this.numOfPages).keys();
this.pages= a;
}
onSomePageClicked(page){
this.onPageClicked.emit(page);
}
}
一切都在开始工作。点击页面也会发出事件。但是当事件由于某种原因被发送时this.pages
变量是空数组。在beggining是7个元素数组,因为我这样调用这个组件:
<pagination [numOfPages]="7" (onPageClicked)="onPageItemClicked($event)"></pagination>
答案 0 :(得分:1)
使用Set WshShell = CreateObject("WScript.Shell")
currentProgram=wscript.ScriptName
Const strComputer = "."
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
query="SELECT * FROM Win32_Process WHERE Name = 'wscript.exe' "
Set colProcessList = objWMIService.ExecQuery(query)
For Each objProcess in colProcessList
If (InStr (objProcess.commandLine,wscript.ScriptName) <> 0 )Then
processDetails="Current ProcessId : "& objProcess.ProcessId & " \n, And Process Name:" & objProcess.name &"\n CommandLine is :"& objProcess.CommandLine
message = msgbox(processDetails,16,"Details")
End If
并忽略TypeScript错误,您将自己摔倒在地。
如果您尝试编译行
any
您将收到错误消息“初始化程序类型IterableIterator无法分配给变量类型编号[]”。
因此TypeScript会告诉您,您做错了,并且通过添加var a = Array(this.numOfPages).keys();
this.pages= a;
来假装它是错误的。它是正确的。 <any>
不返回数组。所以只需修复代码并创建一个真正的数字数组:
Array(this.numOfPages).keys()