a: AA[];
b: AA;
ngOnInit() {
this.a = [];
}
x() {
this.a = [...this.a, this.b]; <--- ?
}
a: AA[];
b: AA;
ngOnInit() {
this.a = [];
}
x() {
this.a = [...this.a, this.b]; <--- ?
}
I hope I can help the subject!
babel
this.a = [...this.a, this.b];
this.a = [].concat(_toConsumableArray(this.a), [this.b]);
from this function we can see that if a new array clone is created for an array, otherwise the Array.from method will be called to create a new array instance from a similar array or iterable object
function _toConsumableArray(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; iPP) {
arr2[i] = arr[i]; } return arr2;
} else {
return Array.from(arr);
}
}
[...'test',10]; // ['t','e','s','t',10]
//
this.a = [...this.a, this.b];
this.a -> => this.a [].concat() this.b
you can go in and have a look at specific examples.
there is currently a header.component.ts public header component that I cannot use in other modules after I register with app.module.ts. other modules are also registered with app.module.ts. < H2 > app.module.ts < H2 > @NgModule({ declarations :...
I want to see how to close the router page or return to the previous router page after the user enters the page. A prompt box appears when the user clicks OK and then closes or returns. Can bosses do this? ...
I ve been learning the angular2 framework recently, and I don t find it too difficult to understand syntax, but the rxjs used in state management is really big. Would like to ask all of you using angular2 framework development students are familiar wit...
in angular2, onChange is called when the immutable value changes, so how can it be detected when the mutable value changes, such as changing the Object,Array, or what rxjs method can solve. ...
Code parent component html: < ng-container * ngComponentOutlet= "switchComponent " > < ng-container > ts: public switchComponent = null; constructor () { this.switchComponent = PatientRecordComponent; } subcomponents < div * ngif= "false " ...
some scenarios are encountered during the development process using the angular4 framework. for example: there is a global drop-down list in the common component, and every time the value of the drop-down list changes, all activated subcomponents change...
<div class="navTab swiper-container" id="nav"> <ul class="nav-ul swiper-wrapper"> <li class="nav-item swiper-slide">< li> <li class="nav-i...
can multiple < router-outlet > tags exist on a page at the same time and display content? encountered a picture in which there is a contractible list on the left side of header, and the display area exists at the same time -main.component.html- <...
now using Angular to make an app, is baffled by an effect. as shown in figure what you want to achieve is the effect of regular scrolling upward. After a period of time, scroll up a message. How should it be realized in Angular? ...
how do I migrate a project developed by Angular2 to Mini Program? what I find is basically mpvue or angularJS. I just need the general steps, and I ll do the rest myself. ...