Sharing Top Content from the Angular-sphere.

5 Features To Watch Out For in Angular v4 ― Scotch

  • They include but not all:
    if…else syntax in component HTML templates
    Stand alone animation module
    TypeScript’s StrictNullChecks compliancy
    Angular Universal adoption by team to live in core
    Performance boost with FESM
    Installation
    Angular v4 is in RC; this means you can start using it in your project hoping that no breaking changes will be released at final.
  • With Angular v4 (RC), you can use the else syntax to handle such case:
    Syntax:
    element *ngIf=”[condition expression]; else [else #hidden
    pYou are not allowed to see our secret/p
    /ng-template
    p *ngIf=”shown; else hidden”
    Our secret is being happy
    /p
    export class AppComponent implements OnInit {
    shown: Boolean;
    auth: Observable{};

    ngOnInit() {
    this.shown = false;
    }
    }
    DOM Output:
    !

  • So if you wanted to use the animation features, your import would look like this:
    import {
    Component,
    OnInit
    // Animation members
    animate,
    state,
    style,
    transition,
    trigger } from ‘@angular/core’
    Angular will no longer allow you to do that, rather, you should import those animation members from @angular/animations:
    import {Component, OnInit} from ‘@angular/core’;

    import {
    animate,
    state,
    style,
    transition,
    trigger } from ‘@angular/animations’
    3.

  • Now, TypeScript allows you to explicitly say a variable can have any of those types:
    let x = String | null
    let y = Number | undefined
    let z = ArrayString | null | undefined
    The above example simple says:
    x can have a value of type String or a null value
    y can have a value of type Number or can be undefined
    z can have a value of type Arrays with String members, can be a null or can be undefined
    This feature is now compliant in Angular (v4), so you could do stuff like this:
    export class AppComponent implements OnInit{

    canBeNull: String | null;
    canBeUndefined: Number | undefined;
    canBeNullOrUndefined: String | null | undefined;

    ngOnInit() {
    this.canBeNull = null;
    console.log(this.canBeNull); // null

    this.canBeUndefined = undefined;
    // undefined

    this.canBeNullOrUndefined = null;
    //null
    this.canBeNullOrUndefined = undefined;
    // undefined
    }
    }
    4.

  • The project was maintained entirely outside Angular, but from Angular v4 forward, Universal will become a core Angular module.

By now, most probably, we have come in peace with the fact that Angular will be rolling out features using semantic versioning. This means we’ve got to worry less about nor entirely new concept (at least for now).

@Jay_Developer: #angular4
5 Features To Watch Out For in Angular v4

#AngularJS #Angular #Laravel #webapps…

By now, most probably, we have come in peace with the fact that Angular will be rolling out features using semantic versioning. This means we’ve got to worry less about nor entirely new concept (at least for now).

Angular skipped version 3 to v4 so as to sync all the different modules. The sync was broken when the Router module was already at v3, and the other modules with no API breaking changes were still at v2. Jacky Kimani announced v4 here at Scotch and highlighted some important points worth noting about this version.

Angular v4 is now released!

With v4 in RC, there are awesome features that are worth your time. They include but not all:

Angular v4 is in RC; this means you can start using it in your project hoping that no breaking changes will be released at final. To install, run the following command:

The installation requires an update to TypeScript.

template literal used for making decision based on some JavaScript-like expression:

syntax to handle such case:

Syntax:

Example:

DOM Output:

Let’s have a look at a possibly realistic example:

syntax to display a loading message while it waits:

. So if you wanted to use the animation features, your import would look like this:

Now, TypeScript allows you to explicitly say a variable can have any of those types:

The above example simple says:

This feature is now compliant in Angular (v4), so you could do stuff like this:

Server-side rendering is the act of spitting the same HTML content in virtual DOM to the server so that they are rendered appropriately by the browser on request. This allows spiders and web robots to dig your websites and index contents when necessary.

Server-side rendering was not a thing in canonical web development until single page apps came about. Such apps use a virtual DOM concept which abstracts DOM rendering. A technique is needed to render to DOM via server requests, and Angular has a solution called Angular Universal which we have previously talked about.

The project was maintained entirely outside Angular, but from Angular v4 forward, Universal will become a core Angular module. Henceforth, you can easily do this:

Rob’s example is a perfect and easy place to see how the integration works out.

5. FESM

Meaning: Flattened ECMAScript Module

This is a very important update that you will likely never notice. Angular v4 ships flattened versions of modules in the ECMAScript Module format. Quoting the changelog:

has increased drastically.

A few things to watch out for:

With all these information, feel free to start experimenting this shiny version. It would also be nice to help the team and community by filing issues if you come across a weird behavior from setting up to usage. You can also read about other features and bug fixes if you think it’s necessary.

5 Features To Watch Out For in Angular v4 ― Scotch

Comments are closed, but trackbacks and pingbacks are open.