angular7

Repeated elements with dynamic datas code optimize in angular7

旧时模样 提交于 2019-12-26 13:25:29
问题 I need to stop a one set of elements repeated in my angular 7 application. That set of elements are working with dynamic data. So I create that set of elements in one component. But I can't call that component inside of that component. 回答1: I got a solution for that <ul> <li *ngFor='let link of links'> <ng-container *ngTemplateOutlet="simpleLink; context:{link:link}"> </ng-container> </li> </ul> <ng-template #simpleLink let-link='link'> Simple : {{ link.name }} <ul> <li *ngFor='let link of

Repeated elements with dynamic datas code optimize in angular7

ぃ、小莉子 提交于 2019-12-26 13:23:07
问题 I need to stop a one set of elements repeated in my angular 7 application. That set of elements are working with dynamic data. So I create that set of elements in one component. But I can't call that component inside of that component. 回答1: I got a solution for that <ul> <li *ngFor='let link of links'> <ng-container *ngTemplateOutlet="simpleLink; context:{link:link}"> </ng-container> </li> </ul> <ng-template #simpleLink let-link='link'> Simple : {{ link.name }} <ul> <li *ngFor='let link of

I want to create a custom event which can trigger from any component and get listened to any component within my angular 7 app

折月煮酒 提交于 2019-12-26 02:43:58
问题 I want to create a custom event which can trigger from any component and get listened to any component within my angular 7 app Suppose I have 1 component in which I have a button on click on which I want to trigger my custom event with some data. Next, there will be another component which will constantly listening for that event when it triggers it will execute some code and update the ui accordingly. How should I implement it? 回答1: Well, well, well, what you're looking for is a Shared

I want to create a custom event which can trigger from any component and get listened to any component within my angular 7 app

泄露秘密 提交于 2019-12-26 02:43:05
问题 I want to create a custom event which can trigger from any component and get listened to any component within my angular 7 app Suppose I have 1 component in which I have a button on click on which I want to trigger my custom event with some data. Next, there will be another component which will constantly listening for that event when it triggers it will execute some code and update the ui accordingly. How should I implement it? 回答1: Well, well, well, what you're looking for is a Shared

Access to XMLHttpRequest at 'http://localhost:3000/' from origin 'http://192.168.X.X:XX' has been blocked by CORS policy [duplicate]

和自甴很熟 提交于 2019-12-25 18:34:56
问题 This question already has answers here : Why doesn't adding CORS headers to an OPTIONS route allow browsers to access my API? (29 answers) Closed 9 months ago . Trying to access Node server (http://localhost:3000) from Angular 7 (http://192.168.X.X) Set CORS i.e. this.app.use(cors()) this.app.use(bodyParser.json()) this.app.use(bodyParser.urlencoded({ extended: false })) but getting Access to XMLHttpRequest at 'http://localhost:3000/' from origin 'http://192.168.X.X:XX' has been blocked by

Service property is not accessible in component.html

限于喜欢 提交于 2019-12-25 04:02:05
问题 My intention is to create print module as detailed in this article. I am getting following error while loading my app.component.html: AppComponent.html:1 ERROR TypeError: Cannot read property 'isPrinting' of undefined App.component.html <div [class.isPrinting]= "printService.isPrinting"> <div style="text-align:center"> <h1> Welcome to {{title}}! </h1> <button (click) ="onPrintReport()"> Print Report</button> <router-outlet name='print"'></router-outlet> </div> </div> App.component.ts import {

Angular 7 only visible rows of paginated data table of angular material 6 are exported instead of the whole array using xlsx library

不想你离开。 提交于 2019-12-25 03:44:26
问题 I need to export an angular material data table into excel file, using xlsx library. The issue is that, if I am using pagination within the data table, and on export, only the visible rows are exported: exportTable() { //let data = Object.values(this.dataSource); const ws: xlsx.WorkSheet=xlsx.utils.table_to_sheet(this.table.nativeElement); const wb: xlsx.WorkBook = xlsx.utils.book_new(); xlsx.utils.book_append_sheet(wb, ws, 'All Data Export'); /* save to file */ xlsx.writeFile(wb,

Angular 7 and Angular Material table with data source error when generating drop list form control for each row

大憨熊 提交于 2019-12-25 03:34:34
问题 Based on this question on stack, I need to bind a drop down list, for each row generated from angular material table dataSource . The drop down list should select automatically the correspondent value, as other values. This is table: <form [formGroup]="formGroup"> <table mat-table [dataSource]="dataSource" matSort> <!-- <ng-container matColumnDef="ind_id"> <th mat-header-cell *matHeaderCellDef> Ind. ID </th> <td mat-cell *matCellDef="let element"> {{element.iid}} </td> </ng-container> --> <ng

Angular 7 production build does not load styles and js

拈花ヽ惹草 提交于 2019-12-25 03:29:51
问题 I have a small project written in Angular 7 and im trying to build the production version out of it. When i run ng build --prod --aot --service-worker The build will run without errors as seen on screenshot. On the other hand, when im trying to load the app in the browser, it will throw errors in console and will not load at all. Any ideas what is causing this? The files are in the same directory as the index.html and they do exist. 回答1: So, I figured out that if I want to serve this files

Angular 7, nested function using same variable

a 夏天 提交于 2019-12-25 03:21:12
问题 I'm trying to run one function - "createThreeDates()" that can generate three different results (dates based on -90, -60, -45), using the same variable. After a user sets a date in the input field, that date variable is set and used in the function. The Generate 1 button calls the function. Everything works fine if I only needed one date (not three). FYI, this function uses the installed/import package "add-subtract-date." There are NO ERRORS in my code, but the function returns the SAME date