Can’t bind to ‘formControl’ since it isn’t a known property of ‘input’ – Angular2 Material Autocomplete issue

While using formControl, you have to import ReactiveFormsModule to your imports array. Example: import {FormsModule, ReactiveFormsModule} from ‘@angular/forms’; @NgModule({ imports: [ BrowserModule, FormsModule, ReactiveFormsModule, MaterialModule, ], … }) export class AppModule {}

Binding select element to object in Angular

<h1>My Application</h1> <select [(ngModel)]=”selectedValue”> <option *ngFor=”let c of countries” [ngValue]=”c”>{{c.name}}</option> </select> StackBlitz example NOTE: you can use [ngValue]=”c” instead of [ngValue]=”c.id” where c is the complete country object. [value]=”…” only supports string values [ngValue]=”…” supports any type update If the value is an object, the preselected instance needs to be identical with one of the … Read more

Unable to resolve dependency tree error when installing npm packages

This is not related to an HTTP proxy. You have dependency conflict (incorrect and potentially broken dependency) as it says, so try to run the command with –force, or –legacy-peer-deps. If it doesn’t take effect, the temporary solution is using prior versions of the Node.js (downgrading the Node.js version) as it causes this kind of … Read more

@Directive vs @Component in Angular

A @Component requires a view whereas a @Directive does not. Directives I liken a @Directive to an Angular 1.0 directive with the option restrict: ‘A’ (Directives aren’t limited to attribute usage.) Directives add behaviour to an existing DOM element or an existing component instance. One example use case for a directive would be to log … Read more

How to go back last page

Actually you can take advantage of the built-in Location service, which owns a “Back” API. Here (in TypeScript): import {Component} from ‘@angular/core’; import {Location} from ‘@angular/common’; @Component({ // component’s declarations here }) class SomeComponent { constructor(private _location: Location) {} backClicked() { this._location.back(); } } Edit: As mentioned by @charith.arumapperuma Location should be imported from @angular/common … Read more

*ngIf and *ngFor on same element causing error

Angular v2 doesn’t support more than one structural directive on the same element. As a workaround use the <ng-container> element that allows you to use separate elements for each structural directive, but it is not stamped to the DOM. <ng-container *ngIf=”show”> <div *ngFor=”let thing of stuff”> {{log(thing)}} <span>{{thing.name}}</span> </div> </ng-container> <ng-template> (<template> before Angular v4) … Read more

How to detect a route change in Angular?

In Angular 2 you can subscribe (Rx event) to a Router instance. So you can do things like class MyClass { constructor(private router: Router) { router.subscribe((val) => /*whatever*/) } } Edit (since rc.1) class MyClass { constructor(private router: Router) { router.changes.subscribe((val) => /*whatever*/) } } Edit 2 (since 2.0.0) see also : Router.events doc class … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)