Showing posts with label beta. Show all posts
Showing posts with label beta. Show all posts

Wednesday, 3 February 2016

Angular 2 templates: Will it parse?


As part of the beta release, we eliminated the requirement for kebab-case in Angular templates and replaced them with case-sensitive names for attributes. This makes it easier for you to write Angular 2 templates that are consistent with naming conventions used in directives.

For example, where you would previously write:
  <my-widget (some-event)="someAction()" [some-property]="expression" #some-var>

You now write:
  <my-widget (someEvent)="someAction()" [someProperty]="expression" #someVar>

Case-sensitivity solves a long-standing confusing issue in Angular 1 where you needed to just know the convention for mapping template attribute names to JavaScript names.  This was an easy pit for novices and even experts to fall into.

Browsers don't differentiate tags by case. Solving the problem required Angular to do its own HTML parsing, so that we could retain the case-sensitive version, and lets us eliminate the mapping convention.

So are Angular 2 templates still valid HTML?  Absolutely.  Per the spec itself, HTML is case-insensitive.  You can freely write whatever case you like and still work with every HTML browser, tool, parser, etc. ever written.

But what if you see validation errors in your favorite tool? It's possible that your tool doesn't follow the HTML specification, or it could be a bug. We're working with tool developers to ensure a smooth experience and would like to hear about issues you encounter. Please file them here.

Just as Angular has always made it possible to create your own elements and attributes that add behaviors beyond the browser's basic set of HTML, the new HTML parser provides benefits by extending the syntax available to templates.

More Benefits

Beyond eliminating the confusion of kebab/camel-case, the HTML parser brings many additional benefits including:

  • Better error messages.  When there are errors, we can now tell you which line and column number they occur on in the template.
  • More consistent.  Whether you're on Chrome, IE, Safari, Firefox or even on the server in node.js we parse the template the same way.  We were able to drop all of the heuristic code required in Angular 1 to account for differences.
  • Enables offline compilation.  We're nearly complete with our next phase of performance optimization where we move all parsing/compiling to a build step.  To make integration with existing build systems as smooth as possible we need to parse the template using Node.js without requiring any browser.
  • Catches errors that browsers don't.  Web browsers are more lenient than the specification and auto-correct errors without telling you.  We want templates to be correct, as these HTML errors can cause real problems when browsers guess wrong.  With this new parser, we've already caught real errors in Google applications and in the Ionic 2 framework.
  • Eliminates typos during development.  You can think of the parser as an HTML validator built into your framework.  We can catch typos in your attribute or tag names and tell you before you ever deploy.
  • Better i18n support. Our new i18n support requires us to parse and understand the templates. Having a custom parser makes this job much easier, reliable and efficient.

Future Work

We're also hard at work on a CSS parser to gain the same benefits and potentially more in the realm of style sheets.  We're basing our Animations and Material Design features on this parser and we'll have early versions of them out soon.
Share:

Tuesday, 15 December 2015

Angular 2 Beta

We're ecstatic to announce that we've reached Angular 2 Beta.  You can read about many of the improvements over Angular 1 in a recent post.  Get started learning Angular 2 now at angular.io.

What does 'beta' mean?

Beta means we're now confident that most developers can be successful building large applications using Angular 2.

Through developer preview and alpha we've worked closely with several large projects here at Google including AdWords, GreenTea (Google's internal CRM system), and Google Fiber.  In fact, just a few weeks ago we saw Google Fiber launch on their new Angular 2 code base.

Externally, we've worked closely with several other teams integrating with Angular 2 including Ionic Framework on Ionic 2, Telerik on NativeScript, Rangle.io on Batarangle, and many others.

We've incorporated the majority of feedback from these teams that would create breaking changes.  Given this, we're looking forward to other teams developing in earnest and telling us how we can help.

Getting Started

Get going now with the updated and expanded Quickstart and Tutorial on angular.io.  From there, you can check out several developer guides and a handy cheatsheet covering the main features in Angular 2.

While the many in-progress Angular 2 books and courses will likely take a few weeks to catch up to the latest changes, we can recommend taking a look at the clear explanations and examples on the thoughtram blog and this in depth primer on Angular 2.

Upgrading from Angular 1

You may have an Angular 1 app today and you want to start writing Angular 2 code in that app, without changing your working/tested angular 1 code. This is where ngUpgrade comes in.

While you can upgrade apps in a "big bang" approach where you halt production until everything is rewritten, we're supporting two paths for where teams want to upgrade their Angular 1 apps to Angular 2.

ngUpgrade

We know many of you made large investments in Angular 1 and have created some awesome apps. We created ngUpgrade for all of you to make it possible to leverage your existing apps and move forward with Angular 2.

ngUpgrade lets you mix Angular 2 into your existing Angular 1 application.  You'll get to take advantage of Angular 2's improved speed and APIs immediately as you replace components a bit at a time over the course of your releases.  Learn more in this article from thoughtram and the upgrade guide in our docs.

ngForward

Some teams, with apps that are more sensitive to download size, will want to avoid having both Angular 1 and Angular 2 libraries running in their app simultaneously.  For this, we have ngForward which lets you write Angular 1 applications in the syntax of Angular 2.  This lets your team get used Angular 2 conventions and styles in your apps today and shorten the distance to doing the full upgrade to Angular 2 when you're ready.

Providing Feedback

As always, please submit issues via GitHub, questions on Stack Overflow, and join the live conversation on Gitter.

We've also recently added a mechanism for submitting feedback for all pages.  Just click on the exclamation point icon in the upper right of the page and tell us what could be improved.

What comes next?

We're already hard at work on the set of improvements to move Angular 2 to its full and final release.  While we will make many small improvements, the big ones for final are:

  1. Reducing Angular 2's payload size.
  2. Making the Angular CLI usable end to end throughout the development process.
  3. Creating a more developer-friendly route definition and link API for the Component Router.
  4. Support for animations.
  5. I18n and L10n support.


And there are even more cool things to come -- some we've already started on including:

  1. More documentation, particularly around ES5/ES6 usage.
  2. Even better startup and runtime performance
  3. An architectural style guide
  4. Unit and end-to-end testing improvements
  5. More support for mobile web and installable mobile apps
  6. Material Design components for Angular 2
  7. A tools platform for deep IDE support
  8. Better support for ES6 and Babel

Thanks, and we're looking forward to seeing the apps you build appear on madewithangular.com!

Share: