ionViewWillEnter vs ionViewDidEnter

sebaferreras answer is great but it is missing some points. First, about ionic life cycle. If you write down all ionic events and put a console.log in each, you will see the scenario: constructor –> ionViewDidLoad –> ionViewWillEnter –> ionViewDidEnter –> ionViewWillLeave –> ionViewDidLeave –> ionViewWillUnload. constructor run first when the page is initiated. This … Read more

How to get angular2 [innerHtml] to work [duplicate]

Angular uses {{property}} for interpolation of values. That is the way that you would display plain text in your div, like so Solution 1: <div class=”blog-post”>{{testhtml}}</div> But that will write out text, not HTML. For HTML, you will need to bind to the property Solution 2: <div class=”blog-post” [innerHtml]=”testhtml”></div> Note I moved the [innerHtml] to … Read more

MatDatePicker start week on monday

You have to build a custom DateAdapter. A custom DateAdapter is a class which implements the DateAdapter interface (it’s actually an abstract class that should be extended). It must have a bunch of predefined function implementations and have to be registered as a useClass for the DateAdapter provider. providers: [{provide: DateAdapter, useClass: CustomDateAdapter }] The … Read more

Can an angular 2 component be used with an attribute selector?

Yes, the selector property of the @Component decorator is a CSS selector (or a subset of): selector: ‘.cool-button:not(a)’ Specifies a CSS selector that identifies this directive within a template. Supported selectors include element, [attribute], .class, and :not(). Does not support parent-child relationship selectors. Source: Angular Cheat Sheet / Directive Configuration, which @Component inherits. That way … Read more

Angular Material Style Class not working

According to Official Documentation of Angular Material: Including a theme is required to apply all of the core and theme styles to your application. To get started with a prebuilt theme, include one of Angular Material’s prebuilt themes globally in your application. You can simply add the following to your style.css in order to get … Read more

angular 2 typescript An implementation cannot be declared in ambient contexts

An implementation cannot be declared in ambient contexts You most probably have your file named as foo.d.ts instead of foo.ts. That marks it as a declaration file (more on that https://basarat.gitbooks.io/typescript/content/docs/types/ambient/d.ts.html) and you cannot put logic in these as you are declaring what logic exists elsewhere.

Angular 2 Final Release Router Unit Test

For testing we now create a testing module using TestBed. We can use the TestBed#configureTestingModule and pass a metadata object to it the same way we would pass to @NgModule beforeEach(() => { TestBed.configureTestingModule({ imports: [ /* modules to import */ ], providers: [ /* add providers */ ], declarations: [ /* components, directives, and … Read more

Angular 2/4 How to style angular material design snackbar

md-snackbar provides a service to provide custom config. One the properties of config is extraClasses that allows to add CSS classes to the snack bar container (doc). extraClasses can be used with ::ng-deep to override the default CSS classes. Here’s an example: component.ts: Requires following import in the component: import {MdSnackBar, MdSnackBarConfig} from ‘@angular/material’; (providing … Read more