angular6

How to make Angular application read cookies at start up

不想你离开。 提交于 2020-01-11 13:07:02
问题 I have an Angular application which on start up should read Cookies ( app.component.ts ) and should redirect to a new component passing the read values. How can I do this? Currently, my server provides the required values as html tag attributes to <app-root> (eg <app-root something="someValue"> ) and the AppComponent reads the attributes using this.el.nativeElement.getAttribute("somethings") . Though it works, I'll prefer to read the values from Cookies or from say an HTTP Header Is there a

How to make Angular application read cookies at start up

筅森魡賤 提交于 2020-01-11 13:06:11
问题 I have an Angular application which on start up should read Cookies ( app.component.ts ) and should redirect to a new component passing the read values. How can I do this? Currently, my server provides the required values as html tag attributes to <app-root> (eg <app-root something="someValue"> ) and the AppComponent reads the attributes using this.el.nativeElement.getAttribute("somethings") . Though it works, I'll prefer to read the values from Cookies or from say an HTTP Header Is there a

Angular 6 - Not able to add text on canvas dynamically

北战南征 提交于 2020-01-11 12:40:32
问题 I have created canvas element. Once user add some text with the help of keyboard, on click of done button I want to add text on canvas. I did below changes 1. image-home.html <canvas (drop)="drop(event)" (dragover)="allowDrop(event)" no-bounce width="400px" height="400" (touchstart)='handleStart($event)' (touchmove)='handleMove($event)' [ngStyle]="{'background': '#fff url(' + selectedImage + ') no-repeat 0 0', 'background-size' : 'contain', 'background-position': 'center', 'background-size':

Angular 6 - Not able to add text on canvas dynamically

让人想犯罪 __ 提交于 2020-01-11 12:40:08
问题 I have created canvas element. Once user add some text with the help of keyboard, on click of done button I want to add text on canvas. I did below changes 1. image-home.html <canvas (drop)="drop(event)" (dragover)="allowDrop(event)" no-bounce width="400px" height="400" (touchstart)='handleStart($event)' (touchmove)='handleMove($event)' [ngStyle]="{'background': '#fff url(' + selectedImage + ') no-repeat 0 0', 'background-size' : 'contain', 'background-position': 'center', 'background-size':

How to replicate normal for loop to *ngFor

爱⌒轻易说出口 提交于 2020-01-07 09:31:14
问题 rating = 4; for(i=0; i < rating ; i++){ //print statement } how to replicate the same for loop with conditions in angular 6 using *ngFor the loop should run based on the rating value.. if it is 2 it should run for 2 times.... 回答1: I think you looking for this kind of solution, Just create one empty array with your rating length component let items = []; for(i=0; i < rating ; i++){ items.push(i); } Use in template like <div *ngFor="let item of items"> </div> 回答2: The best solution I think is

how data binding works between ng-template and the context passed to the template using CreateEmbeddedView

孤者浪人 提交于 2020-01-06 10:04:19
问题 I have this template. <ng-template #thumbnailTemplate let-context="thumbnailContext"> <div id="{{context.divId}}"> <img id="{{context.imgId}}" src="{{context.imgSrc}}"> <a href="#" id="{{context.closeId}}" (click)="this.deleteThumbnail(context)"></a> </div> </ng-template> The following code create a view using the above template thumbnailTemplateViewRef = this.thumbnailContainerRef.createEmbeddedView(this.thumbnailTemplateRef, {thumbnailContext: new ThumbnailContext(divId, imgId, closeId,

Can't bind to 'ngModelOptions' since it isn't a known property of 'input' in Angular 6

喜欢而已 提交于 2020-01-06 08:38:31
问题 Here is my HTML: <nz-form-item nzFlex [formGroup]="hulkForm"> <nz-form-label [nzSpan]="7" [nzFor]="hulkColumn.column" [nzRequired]="hulkColumn.require">{{hulkColumn.lable}}</nz-form-label> <nz-form-control [nzSpan]="17"> <input nz-input placeholder={{hulkColumn.placeholder}} [formControlName]="hulkColumn.name" [(ngModel)]="hulkColumn.model" [ngModelOptions]="{updateOn: 'blur'}" name="{{hulkColumn.name}}" *ngIf="hulkColumn.type!=='number'" > </nz-form-control> </nz-form-item> Here is the error

PrimeNg Chart in stackblitz not running?

谁说胖子不能爱 提交于 2020-01-06 07:13:55
问题 This is the first time i am trying to make an stackblitz app with Angular6, Primeng 6 . I am trying to create Primeng chart with it. I installed Chartjs and also updated the angular.json file, as given in Primeng documentation but it is throwing error saying Chart is not defined. Can anyone help me to resolve this issue. Same thing is working perfectly in my local setup. Here is the link: stackblitz link 回答1: Placing these two script lines in the index.html file allows it to run natively in

Nested tree Structure Data Generation

余生长醉 提交于 2020-01-06 07:13:29
问题 please bare with my English and writing question, i have a array of json data which i am trying to make it in a nested tree structure but not getting success , hope someone can help me out. My Example Data: [ { "id" : 1, "name" : "Abc", "path" : "/", "type" : "folder" }, { "id" : 2, "name" : "Xyz", "path" : "/Abc/", "type" : "folder" }, { "id" : 3, "name" : "Pqr", "path" : "/Abc/Xyz/", "type" : "folder" }, { "id" : 4, "name" : "Zap", "path" : "/Abc/Xyz/Pqr/", "type" : "folder" },{ "id" : 5,

multi page registration form in angular 6

寵の児 提交于 2020-01-06 07:10:29
问题 I have a parent component as under and 4 child components for registration. The data is not visible if i retrun from step L2 to L1. Any idea? <div class="container-fluid page-content" mat-dialog-content> <div class="row"> <ul class="nav nav-pills nav-justified"> <li [ngClass]="{'active': this.actL1}"><a (click)="onClick('l1')" data-toggle="pill">L1</a></li> <li [ngClass]="{'active': this.actL2}"><a (click)="onClick('l2')" data-toggle="pill">L2</a> </li> <li [ngClass]="{'active': this.actL3}">