angular

Angular routing keep child parameters

空扰寡人 提交于 2021-02-10 16:16:01
问题 I have the following route configuration: const routes: Routes = [ { path: '', component: HomeComponent, canActivate: [AuthGuard], children: [ { component: DashboardComponent, path: '' }, { component: UnitComponent, path: 'unit/:serialnumber', children: [ { path: '', redirectTo: 'realtime', pathMatch: 'full'}, { path: 'manager', component: UnitManagerComponent, canActivate: [SysAdminGuard] }, { path: 'realtime', component: UnitRealtimeComponent }, { path: 'history', component:

Angular 7 -Sort select drop down options in custom order

别来无恙 提交于 2021-02-10 16:09:46
问题 I have a select drop down where options are fetched from service dynamically using *ngFor .I want to reorder the options order in my custom way. is it possible to do from angular code. The array is like this console.log(this.paymentTypeData); Array(5) 0: {value: "DAILY", code: "D", label: "Daily"} 1: {value: "SINGLE_TIER", code: "ST", label: "Single Tier"} 2: {value: "MULTI_TIER", code: "MT", label: "Multi Tier"} 3: {value: "NO_DISCOUNT", code: "ND", label: "No Discount"} 4: {value: "EOM",

Angular 7 -Sort select drop down options in custom order

混江龙づ霸主 提交于 2021-02-10 16:09:15
问题 I have a select drop down where options are fetched from service dynamically using *ngFor .I want to reorder the options order in my custom way. is it possible to do from angular code. The array is like this console.log(this.paymentTypeData); Array(5) 0: {value: "DAILY", code: "D", label: "Daily"} 1: {value: "SINGLE_TIER", code: "ST", label: "Single Tier"} 2: {value: "MULTI_TIER", code: "MT", label: "Multi Tier"} 3: {value: "NO_DISCOUNT", code: "ND", label: "No Discount"} 4: {value: "EOM",

Angular 7 -Sort select drop down options in custom order

ⅰ亾dé卋堺 提交于 2021-02-10 16:09:09
问题 I have a select drop down where options are fetched from service dynamically using *ngFor .I want to reorder the options order in my custom way. is it possible to do from angular code. The array is like this console.log(this.paymentTypeData); Array(5) 0: {value: "DAILY", code: "D", label: "Daily"} 1: {value: "SINGLE_TIER", code: "ST", label: "Single Tier"} 2: {value: "MULTI_TIER", code: "MT", label: "Multi Tier"} 3: {value: "NO_DISCOUNT", code: "ND", label: "No Discount"} 4: {value: "EOM",

How to use an object as the default value in Angular FormControl (without using a reference)?

你离开我真会死。 提交于 2021-02-10 15:59:56
问题 I am creating a select element, and want to set an object as the default value when the application starts. In my example I have a list of animals, and a FormControl used in an HTML template. I tried adding an object (not a reference to an object) directly to the formControl like this: animalControl = new FormControl({name:'Dog', sound: 'Woof!'}, [Validators.required]); // this does not work This does not work. However, referencing an object from the actual list works, like this: this

ESLint error when trying to lint Angular templates

杀马特。学长 韩版系。学妹 提交于 2021-02-10 15:58:08
问题 I have an Angular 10 app set up with eslint and prettier, which worked fine so far for linting Typescript files. I'm now trying to lint my component template files as well following this doc. But when I run it with eslint . --ext .js,.ts,.component.html --fix I keep getting Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript

ESLint error when trying to lint Angular templates

被刻印的时光 ゝ 提交于 2021-02-10 15:56:59
问题 I have an Angular 10 app set up with eslint and prettier, which worked fine so far for linting Typescript files. I'm now trying to lint my component template files as well following this doc. But when I run it with eslint . --ext .js,.ts,.component.html --fix I keep getting Error while loading rule '@typescript-eslint/dot-notation': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript

Angular: strictTemplates - How to set boolean and numbers in Templates properly?

依然范特西╮ 提交于 2021-02-10 15:47:21
问题 I set strictTemplates:true and use in a HTML template the following <textarea matInput matAutosizeMaxRows="4" matTextareaAutosize="true" I receive from the compiler error TS2322: Type 'string' is not assignable to type 'number'. error TS2322: Type 'string' is not assignable to type 'boolean'. But how to set it properly in the HTML-Templates (to avoid the error)? 回答1: Wrap the property name in brackets. If you leave the brackets, the values will be interpreted as strings. With brackets, the

vAxis Single line label in angular-google-chart

天涯浪子 提交于 2021-02-10 15:46:30
问题 I am using angular-google-chart to implement google chart in my angular app, when the y axis labels (marked with red color) is too long it in coming up in three lines then showing "..." , i want only one one line to show up instead of 3, how this can be achieved. Any help is most appreciated. 回答1: in the chart's configuration options, you can add more room for the labels using the chartArea option... var options = { chartArea: { left: 600 } }; you can also reduce the font size using the

In Angular 9, why are my subscriptions getting loaded sequentially instead of in parallel?

谁说胖子不能爱 提交于 2021-02-10 15:46:14
问题 I'm using Angular 9. I want to load a series of objects, each of which has image data. I would like to load all the objects, first, and then load the image data after. I have this in my component.ts file ngOnInit ... ngOnInit(): void { this.authService.getAllinLibrary().subscribe((res: any[]) => { this.results = res; ... for (let i = 0; i < results.length; i++) { this.getTheImage(res[i].Id, i); } }); getTheImage(imageId: number, index: number) { this.authService.getPersonImage(imageId)