Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
122
rated 0 times [  125] [ 3]  / answers: 1 / hits: 15222  / 7 Years ago, wed, june 21, 2017, 12:00:00

The Problem:



I'm receiving a Typescript 2.2.1 compilation error when trying to append a compiled angular 1.5 template to an existing HTMLElement.



Code:



$document.find(scope.target)[0].append($compile(menu)(scope)[0]);


Compile error:



[ts] Property 'append' does not exist on type 'HTMLElement'


I've searched through the type definitions and don't see a signature for append().



Any ideas as to which type or version of typescript I should be using?



Thanks!


More From » angularjs

 Answers
57

Here there is nothing to do with TypeScript.



The correct method to call is appendChild:



https://developer.mozilla.org/en/docs/Web/API/Node/appendChild



append is a jQuery method, and if you want to use that you could do:



$document.find(scope.target).append($compile(menu)(scope)[0]);



and it should work too.



I hope it helps


[#57351] Tuesday, June 20, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kenyamelinad

Total Points: 339
Total Questions: 85
Total Answers: 116

Location: Marshall Islands
Member since Sun, Aug 29, 2021
3 Years ago
;