javascript - Error with Syntax Angular 4 app -
i getting weird error regarding syntax when see console log in chrome, it's regarding line uses $event.target. if take out, error goes away. not sure why can't use $event.target in button. find code html, js/typescript, , error log in attachments.
why passing $event.target method end looking element jquery? element not string, it's object.
i go way:
<button class="btn-script" #listbtn (click)="addtolist(listbtn)"> that pass reference button elementref - holds reference underlying dom element .nativeelement
addtolist(button: elementref) { // can still imperative stuff here if like: button.nativeelement.parentelement.children(... // or $(button.nativeelement).siblings(... } my advice though, embrace declarative nature of angular , start manipulating model(s) known both in code , in markup/template.
go check out the tour of heroes on official angular site. you'll glad did :)


Comments
Post a Comment