angular 4: *ngIf with multiple conditions

Besides the redundant ) this expression will always be true because currentStatus will always match one of these two conditions: currentStatus !== ‘open’ || currentStatus !== ‘reopen’ perhaps you mean one of !(currentStatus === ‘open’ || currentStatus === ‘reopen’) (currentStatus !== ‘open’ && currentStatus !== ‘reopen’)

What is multi provider in angular2

multi: true means that one provider token provides an array of elements. For example all directives for router support routerLink, router-outlet are provided by ROUTER_DIRECTIVES. If a new provider is registered with the token ROUTER_DIRECTIVES, then it overrides the previously registered directives. If multi: true (on the first registered and the new provider) is set, … Read more

Angular: Cannot find a differ supporting object ‘[object Object]’

I think that the object you received in your response payload isn’t an array. Perhaps the array you want to iterate is contained into an attribute. You should check the structure of the received data… You could try something like that: getusers() { this.http.get(`https://api.github.com/search/users?q=${this.input1.value}`) .map(response => response.json().items) // <—— .subscribe( data => this.users = data, … Read more

How to use multiple ng-content in the same component in Angular 2?

You can wrap ng-content in ng-template and use ngTemplateOutlet <a class=”bouton” href=”https://stackoverflow.com/questions/44699469/{{ href }}” *ngIf=”hasURL”> <ng-container *ngTemplateOutlet=”contentTpl”></ng-container> </a> <button class=”bouton” *ngIf=”!hasURL”> <ng-container *ngTemplateOutlet=”contentTpl”></ng-container> </button> <ng-template #contentTpl><ng-content></ng-content></ng-template> Plunker Example See also How to conditionally wrap a div around ng-content Angular 9 demo

Get reference to a directive used in a component

You can use exportAs property of the @Directive annotation. It exports the directive to be used in the parent view. From the parent view, you can bind it to a view variable and access it from the parent class using @ViewChild(). Example With a plunker: @Directive({ selector:'[my-custom-directive]’, exportAs:’customdirective’ //the name of the variable to access … Read more

svg circle – Can’t bind to cx since it isn’t a known native property

In order to bind to SVG element attributes in Angular, you must prefix them with attr: For your circle this will be: <svg height=”100″ width=”100″> <circle fill=”white” [attr.cx]=”parsedSize/2″ [attr.cy]=”parsedSize/2″ [attr.r]=”radius” [attr.stroke]=”stroke” [attr.stroke-width]=”strokeWidthCapped” [attr.stroke-dasharray]=”circumference” [attr.stroke-dashoffset]=”(1 – parsedComplete) * circumference”/> </svg> I am not entirely sure if it should be [attr.stroke-width] or [attr.strokeWidth], but give it a … Read more

How to pass object from one component to another in Angular 2?

For one-way data binding from parent to child, use the @Input decorator (as recommended by the style guide) to specify an input property on the child component @Input() model: any; // instead of any, specify your type and use template property binding in the parent template <child [model]=”parentModel”></child> Since you are passing an object (a … Read more

Pass parameters with EventEmitter

EventEmitter supports one argument, which is passed as $event to your event handler. Wrap your parameters in an event object when you pass it to emit: this.stopSort.emit({ event:event, ui: ui }); Then, when you handle the event, use $event: stopSort($event) { alert(‘event param from Component: ‘ +$event.event); alert(‘ui param from Component: ‘ + $event.ui); } … Read more

Difference between [ngClass] vs [class] binding

This is special Angular binding syntax <div [class.extra-sparkle]=”isDelightful”> This is part of the Angular compiler and you can’t build a custom binding variant following this binding style. The only supported are [class.xxx]=”…”, [style.xxx]=”…”, and [attr.xxx]=”…” ngClass is a normal Angular directive like you can build it yourself <div [ngClass]=”{‘extra-sparkle’: isDelightful}”> ngClass is more powerful. It … Read more

What is the difference between component and directive?

Basically there are three types of directives in Angular2 according to documentation. Component Structural directives Attribute directives Component It is also a type of directive with template,styles and logic part which is most famous type of directive among all in Angular2. In this type of directive you can use other directives whether it is custom … Read more