i've got component needs call function in mydirective can't figure out how gain access it, keeps spewing out errors no matter try. i looked @ view child in docs didn't work me, don't show template usage can't sure if i'm doing right. edit: i think it's important note directive imports component, importing directive component seems give circular reference, causing mydirective become undefined if try inject directives:[] part of @component decorator. what need this: component: import {mydirective} 'my-directive.directive'; // shortened example's sake @component({ directives: [mydirective] }) export class { @viewchild(mydirective) mydir: mydirective; } component template: <button (click)="mydir.mydirectivefunc()"></button> what don't want declare mydirective on button because add undesired behavior. want gain access functions. how can this?
here trying do: trying solve issue has wrapping in text file. i want open txt file, read line , if line contains want contain, check next line see if not contain in first line. if not, add line first line. import re stuff = open("my file") line in stuff: if re.search("from ", line): first = line print first if re.search('from ', handle.next()): continue else: first = first + handle.next() else: continue i have looked quite few things , cannot seem find answer. please help! i try this, invalid triples of "from " , not elegant @ all. lines = open("file", 'r').readlines() lines2 = open("file2", 'w') counter_list=[] last_from = 0 counter, line in enumerate(lines): if "from " in line , counter != last_from +1: last_from = counter current_count = counter if current_coun...
Comments
Post a Comment