angular2 style guide – property with dollar sign?

$ suffix (popularized by Cycle.js) is used to indicate that the variable is an Observable. It could make it to the official style guide too but it’s not there yet Read more here : What does the suffixed dollar sign $ mean? Update: Read more about the trailing “$” sign on Angular website here: https://angular.io/guide/rx-library#naming-conventions-for-observables

Use component from another module

The main rule here is that: The selectors which are applicable during compilation of a component template are determined by the module that declares that component, and the transitive closure of the exports of that module’s imports. So, try to export it: @NgModule({ declarations: [TaskCardComponent], imports: [MdCardModule], exports: [TaskCardComponent] // <== export the component you … Read more

tslint / codelyzer / ng lint error: “for (… in …) statements must be filtered with an if statement”

To explain the actual problem that tslint is pointing out, a quote from the JavaScript documentation of the for…in statement: The loop will iterate over all enumerable properties of the object itself and those the object inherits from its constructor’s prototype (properties closer to the object in the prototype chain override prototypes’ properties). So, basically … Read more

How to pass query parameters with a routerLink

queryParams queryParams is another input of routerLink where they can be passed like <a [routerLink]=”[‘../’]” [queryParams]=”{prop: ‘xxx’}”>Somewhere</a> fragment <a [routerLink]=”[‘../’]” [queryParams]=”{prop: ‘xxx’}” [fragment]=”yyy”>Somewhere</a> routerLinkActiveOptions To also get routes active class set on parent routes: [routerLinkActiveOptions]=”{ exact: false }” To pass query parameters to this.router.navigate(…) use let navigationExtras: NavigationExtras = { queryParams: { ‘session_id’: sessionId }, … Read more

How can I write data attributes using Angular?

Use attribute binding syntax instead <ol class=”viewer-nav”><li *ngFor=”let section of sections” [attr.data-sectionvalue]=”section.value”>{{ section.text }}</li> </ol> or <ol class=”viewer-nav”><li *ngFor=”let section of sections” attr.data-sectionvalue=”{{section.value}}”>{{ section.text }}</li> </ol> See also : How to add conditional attribute in Angular 2?

What is the proper use of an EventEmitter?

TL;DR: No, don’t subscribe manually to them, don’t use them in services. Use them as is shown in the documentation only to emit events in components. Don’t defeat angular’s abstraction. Answer: No, you should not subscribe manually to it. EventEmitter is an angular2 abstraction and its only purpose is to emit events in components. Quoting … Read more

Importing lodash into angular2 + typescript application

Here is how to do this as of Typescript 2.0: (tsd and typings are being deprecated in favor of the following): $ npm install –save lodash # This is the new bit here: $ npm install –save-dev @types/lodash Then, in your .ts file: Either: import * as _ from “lodash”; Or (as suggested by @Naitik): … Read more

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