angular? What"s the difference between
defining variables in constructor?
export class Hero {
id: number;
name: string;
}
export class Hero {
constructor (
public id: number,
public name: string) { }
}
Thank you
angular? What"s the difference between
defining variables in constructor?
export class Hero {
id: number;
name: string;
}
export class Hero {
constructor (
public id: number,
public name: string) { }
}
Thank you
interface Person {
name: string;
age: number;
}
class Zhangsan implements Person {
}
class Zhangsan {
name: string;
age: number;
}
probably means that interface extracts public properties and methods, and class is a specific object
interface just provides a declaration describing what your object looks like, and cannot instantiate
class is to describe what your object looks like
constructor(
public id: number,
public name: string) { }
automatically declares class properties id and name, and automatically assigns values in the constructor
interface is the interface used to standardize class
the class, used by the official demo is supposed to use interface, right? What is particular about
Previous: How to match floating-point exact 1 bits and integers using match
Next: Php+ajax randomly generates problems. $username=$number executes errors like this
when using routing to switch pages, such as A page to B page, if the A page scrolls down, the B page is also scrolling distance when it is routed to B, how to get back to the top of the page each time you switch ...
I saw an example in the angular service subscribe: this.xxService.readBook().subscribe( (data) =>{ console.log(data)}, (err) => { console.log(err) ) is there any other data in subcribe besides data and err? is the order data first and then err...
such as getHeroes (): Observable < Hero [] > { return this.http.get < Hero [] > (this.heroesUrl) } can I just write it this way? getHeroes () { return this.http.get < Hero [] > (this.heroesUrl) } is it necessary to give < Hero [] > after get...
the method of adding parameter content to httpParams. The official way to write it is: const httpParams = new HttpParams().set(key,value).set(key,value).set(key.value); if you want to add multiple parameters, you have to keep .set (), which feels tro...
when testing in the browser, using the back button that comes with the browser does not return the animation. I remember that there are all ionic1. I don t know how to solve it. ...
1. At first, I wrote the interface in each component.ts . 2,server.ts ...
nz-table but it is useless, ask the boss to solve it! http: ng-alain.com https: ng.ant.design -sharp compo. ...
1, display configuration document 2i18n.service.ts } 3 ...
recently started to learn, is still in the tutorial stage, there is a ready-made background to test, but found a problem, angular before and after the project separation mode, will inevitably encounter different port cross-domain problem, why there is no...
follow the course, still request mock data of less than 8000 port "data of port 8000 can be requested directly to , but request 8000 port at port 4001. , help me with some suggestions ...
Uncaught Error: Template parse errors: md-toolbar is not a known element: 1. If md-toolbar is an Angular component, then verify that it is part of this module. git: https: github.com yyccQQu 0405newNg tree dev my-app ...
export class RepeatPasswordDirective implements Validator,OnChanges { * * check method @ param c @ returns {{[p: string]: any}} * validate (c: AbstractControl): {[p: string]: any} { return verifyPassword(c,this.repeatPassword.control); } ...
I want to do a form check so that it can work: flag: Cannot read property invalid of undefined at Object.eval [as updateDirectives] (EditMemberComponent.html:9) I judge that it is the reason why the attributes of name are not automatically gen...
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? ...
to use a rich text editor in the project, I found Quill I introduced into app after npm install ng2-quill-editor. import { QuillEditorModule } from ng2-quill-editor ; imports: [ QuillEditorModule, ], an error will be reported at thi...
Does Angular have a useful draggable tree table control? Ask for recommendation. For example, treegrid for GXT, extjs, easyui. with a node drag event and a right-click Context Memu event. I have searched all kinds of control libraries on the Internet a...
loadchidren settings.module.ts routing error access http: localhost:4200 settings Error: Component SettingsComponent is not part of any NgModule or the module has not been imported into your module. error app-routing.module.ts (ma...
ionic3angular5ionic3alertControllerionic3es6alertconfirm ionic1+angularjs1+JavaScriptalertconfirmfunctionoptionionic1$popupoptions ...
Why ie is different from the default selection of Google browser s select box. It is also option tag * ngFor circular data. But ie is the first one selected by default, and Google browser does not display it by default. How to make ie not show sele...
1.Angular5 animation has no effect after setting animate transition time 2. Code: import { Component } from @angular core ; import { OverlayContainer } from @angular cdk overlay ; import { trigger, state, transition, style, animate, keyframes } ...