angular5

Receive AccessDenied when trying to access a reload or refresh or one in new tab in angular 5

随声附和 提交于 2019-12-23 03:52:00
问题 For a while, I was simply storing the contents of my website in a s3 bucket and could access all pages via the full url just fine. I wanted to make my website more secure by adding an SSL so I created a CloudFront Distribution to point to my s3 bucket. The site will load just fine, but if the user tries to refresh the page or if they try to access a page using the full url (i.e., www.example.com/home), they will receive an AccessDenied page. 回答1: S3 doesnt understand route open when you

Angular 5 Form validation and display error in generic component

那年仲夏 提交于 2019-12-23 03:26:05
问题 I have a generic component like below, // selector: 'app-text-box' <form> <input type="text" [name]="data.name" [id]="data.name"/> </form> <error-message [message]="message"></error-message> Also my app component like below, <div *ngFor="let data of jsonData | async"> <app-text-box [data]="data" *ngIf="data.type === 'TEXT'"> </app-text-box> </div> And then my json [ { "type": "TEXT", "name": "book" }, { "type": "TEXT", "name": "note" } ] based on the above json, the app component will iterate

chartjs-plugin-annotations not displayed in angular 5

送分小仙女□ 提交于 2019-12-23 02:55:13
问题 While using the chart.js and the plugin chartjs-plugin-annotation, annotations are not showing while using angular 5, no error messages are displayed. I have created a cut down example of code that exhibits the problem console.log(Chart.plugins) shows the plugin looks to be registered as plugin[3] however it doesn't have an id as the inbuilt ones do, is this a problem? chart.component.ts import { Component, Inject } from '@angular/core'; import { Chart } from 'chart.js'; import 'chartjs

How to call an external jQuery functions in angular

若如初见. 提交于 2019-12-23 02:44:15
问题 I am working on an Angular CLI Project where I need to call some jQuery functions. I have included my js in the angular.json file: "scripts": [ "node_modules/jquery/dist/jquery.min.js", "src/custom.js" ] jQuery function : function A() { alert('A'); } function B() { alert('B'); } I have imported jQuery in my component where I need to call these jQuery functions :- import * as $ from 'jquery'; tsconfig.app.json : { "extends": "../tsconfig.json", "compilerOptions": { "outDir": "../out-tsc/app",

Render Components from Array loop

一世执手 提交于 2019-12-22 13:48:37
问题 In my app.component.ts I have an array with the component tags. compData = ['app-component-one', 'app-component-two', 'app-component-three']; Then in my app.component.html I have this: <div *ngFor="let comps of compData"> // I tried this: {{comps}} but that will not render the components </div> How can I do this so I can render each component? 回答1: You cannot render components from array, instead you need to look at dynamic component generator https://angular.io/guide/dynamic-component-loader

Passing for variable to ng-content

↘锁芯ラ 提交于 2019-12-22 10:08:05
问题 How do I pass an ngFor variable to the ng-content template. Example, the containing-component: <ul> <li *ngFor="let item of itemsArray"> <ng-content></ng-content> </li> </ul> The nested content-component: <div> <span *ngIf="item.type_one"></span> <span *ngIf="item.type_two"></span> </div> Example, both: <containing-component> <content-component> </content-component> </containing-component> 回答1: You can not use ng-content as dynamic template. Use ng-template instead <ul> <li *ngFor="let item

Angular 5 remove specific DOM elements

核能气质少年 提交于 2019-12-22 08:19:50
问题 I have a small issue that I can't figure out how to do. I am just learning Angular / Typescript and I can't figure out how I could remove some DOM elements. I have some auto generated content, that has specific CSS classes. Unfortunately The objects are generated somewhere else and I cannot configure them in any way so I cannot add any ngIf or anything else on that content, that would simplify my work... I just have to use them. What I want to achieve is something like this( jQuery version):

MatSort is undefined - Angular 5

跟風遠走 提交于 2019-12-22 08:12:01
问题 I'm trying to implement a Material table in my angular application. Pagination and Filter are working fine, but i'm not able to sort my table. My reference to MatSort is undefined. I did import it in AppModule: import {MatTableModule} from '@angular/material/table'; import {MatTooltipModule} from '@angular/material/tooltip'; import {MatButtonModule, MatCheckboxModule,MatPaginatorModule,MatInputModule} from '@angular/material'; import {MatSortModule} from '@angular/material/sort'; ...

Angular Material - Getting index of row in data table

早过忘川 提交于 2019-12-22 06:42:51
问题 I am using the MatTable component from Angular Material to make a dynamic data table. I need to get the current position of a row. I can easily get the row on which the user clicked but I am unable to know its current position in the list (which depends on sort/filtering/pagination). Any idea? 回答1: in your mat-cell you can get index like *ngFor as below <mat-cell *matCellDef="let element;let i = index;"> {{ i }} </mat-cell> Update from Angular 5 use also index as i <ng-container matColumnDef=

Angular 5 TypeError: outlet is null / cannot read property 'component' of null while routing

对着背影说爱祢 提交于 2019-12-22 06:12:05
问题 With Angular 5, I am trying to route to a projects page with an parameter id. After being on this page: /project/:projectid and routing in the header again to this page, only with an different ID, it throws: columnNumber: 27683 fileName: "//kleinprodesign.new/assets/js/predependencies/zone.min.js" lineNumber: 1 message: "Uncaught (in promise): TypeError: outlet is null\nPreActivation.prototype.setupRouteGuards@//kleinprodesign.new/angular2-app/node_modules/@angular/router/bundles/router.umd