Angular2 If ngModel is used within a form tag, either the name attribute must be set or the form

If ngForm is used, all the input fields which have [(ngModel)]=”” must have an attribute name with a value. <input [(ngModel)]=”firstname” name=”something”> Standalone By setting [ngModelOptions]=”{standalone: true}” one tells Angular something like, ignore the form and/or ngForm, just bind it to firstname variable please. However, if form-tag was used by mistake (like in my case … Read more

How to get query params from url in Angular 2?

By injecting an instance of ActivatedRoute one can subscribe to a variety of observables, including a queryParams and a params observable: import {Router, ActivatedRoute, Params} from ‘@angular/router’; import {OnInit, Component} from ‘@angular/core’; @Component({…}) export class MyComponent implements OnInit { constructor(private activatedRoute: ActivatedRoute) {} ngOnInit() { // Note: Below ‘queryParams’ can be replaced with ‘params’ depending … Read more

Delegation: EventEmitter or Observable in Angular

Update 2016-06-27: instead of using Observables, use either a BehaviorSubject, as recommended by @Abdulrahman in a comment, or a ReplaySubject, as recommended by @Jason Goemaat in a comment A Subject is both an Observable (so we can subscribe() to it) and an Observer (so we can call next() on it to emit a new value). … Read more

What is the difference between “ng-bootstrap” and “ngx-bootstrap”?

ng-bootstrap and ngx-bootstrap are two different projects by two different project teams that are trying to accomplish more or less the same thing – allowing you to use Bootstrap in Angular (2+) without the use of jQuery. They are both rebuilding the Bootstrap components using only Angular (no jQuery).The main differences are around which version … Read more

Is there a way to remove unused imports and declarations from Angular 2+? [closed]

Edit (as suggested in comments and other people), Visual Studio Code has evolved and provides this functionality in-built as the command “Organize imports”, with the following default keyboard shortcuts: option+Shift+O for Mac Alt + Shift + O for Windows Original answer: I hope this visual studio code extension will suffice your need: https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero It provides … Read more

How to write unit testing for Angular / TypeScript for private methods with Jasmine

I’m with you, even though it’s a good goal to “only unit test the public API” there are times when it doesn’t seem that simple and you feel you are choosing between compromising either the API or the unit-tests. You know this already, since that’s exactly what you’re asking to do, so I won’t get … Read more

Angular2 Exception: Can’t bind to ‘routerLink’ since it isn’t a known native property

>=RC.5 import the RouterModule See also https://angular.io/guide/router @NgModule({ imports: [RouterModule], … }) >=RC.2 app.routes.ts import { provideRouter, RouterConfig } from ‘@angular/router’; export const routes: RouterConfig = [ … ]; export const APP_ROUTER_PROVIDERS = [provideRouter(routes)]; main.ts import { bootstrap } from ‘@angular/platform-browser-dynamic’; import { APP_ROUTER_PROVIDERS } from ‘./app.routes’; bootstrap(AppComponent, [APP_ROUTER_PROVIDERS]); <=RC.1 Your code is missing @Component({ … Read more

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