Error: Cannot read the "push" property from undefined in [null].
class A implements OnInit { stringArr: string[]; ngOnInit() { for(let i=0; i<4; i++) { this.stringArr.push("aaa"); } } }
You need to initialize the array:
stringArr = [];
class A implements OnInit { stringArr: string=[]; ngOnInit() { for(let i=0; i<4; i++) { this.stringArr.push("aaa"); } } }
Here stringArr defined as a string, but not as an array of strings. Define stringArr as an empty array [].
stringArr
Source: https://habr.com/ru/post/1244068/More articles:Plone5 Mockup Widgets like pat-pickadate not working for dynamically generated content - javascriptExpression pandas subset operation using pipe - pythonLaravel 5 UnexpectedValueException on response - phpHow to read child_process.spawnSync stdout with the stdio 'inherit' option - node.jsLaravel 5 UnexpectedValueException in response to a request due to the use of POINT data - phpNodeJS aerodynamics UDF aggregation error - node.jsSort list of dictionary lists in python - pythonWhy does the compiler implicitly convert double to int when an explicit user statement exists from int to Foo? - c #How to put subtitles in mobile videos using Handheld.PlayFullScreenMovie in unity - androidAWS Lambda function continues a bit after context.fail - node.jsAll Articles