Format date as dd/MM/yyyy using pipes

Pipe date format bug fixed in Angular 2.0.0-rc.2, this Pull Request. Now we can do the conventional way: {{valueDate | date: ‘dd/MM/yyyy’}} Examples: Current Version: Example Angular 13 Old Versions: Example Angular 8.x.x Example Angular 7.x Example Angular 6.x Example Angular 4.x Example Angular 2.x More info in documentation DatePipe

Stop mouse event propagation

If you want to be able to add this to any elements without having to copy/paste the same code over and over again, you can make a directive to do this. It is as simple as below: import {Directive, HostListener} from “@angular/core”; @Directive({ selector: “[click-stop-propagation]” }) export class ClickStopPropagation { @HostListener(“click”, [“$event”]) public onClick(event: any): … Read more

What is the correct way to share the result of an Angular Http network call in RxJs 5?

EDIT: as of 2021, the proper way is to use the shareReplay operator natively proposed by RxJs. See more details in below answers. Cache the data and if available cached, return this otherwise make the HTTP request. import {Injectable} from ‘@angular/core’; import {Http, Headers} from ‘@angular/http’; import {Observable} from ‘rxjs/Observable’; import ‘rxjs/add/observable/of’; //proper way to … Read more

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

I missed let in front of talk: <div *ngFor=”let talk of talks”> Note that as of beta.17 usage of #… to declare local variables inside of structural directives like NgFor is deprecated. Use let instead. <div *ngFor=”#talk of talks”> now becomes <div *ngFor=”let talk of talks”> Original answer: I missed # in front of talk: … Read more

Angular EXCEPTION: No provider for Http

Import the HttpModule import { HttpModule } from ‘@angular/http’; @NgModule({ imports: [ BrowserModule, HttpModule ], providers: [], declarations: [ AppComponent ], bootstrap: [ AppComponent ] }) export default class AppModule { } platformBrowserDynamic().bootstrapModule(AppModule); Ideally, you split up this code in two separate files. For further information read: https://v2.angular.io/docs/ts/latest/cookbook/rc4-to-rc5.html https://v2.angular.io/docs/ts/latest/guide/ngmodule.html

ng is not recognized as an internal or external command

I solved this problem in accordance with the figure: run in cmd npm install -g @angular/cli and then ( open in Windows 10) Control Panel\All Control Panel Items\System or accordance with the figure step 1: step 2 : step3: step4: step5: add missing ng path Here is new environment variable that you need add: C:\Users\PK\AppData\Roaming\npm\node_modules\@angular\cli\bin … Read more

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