Angular released 1.5 focusing on the transition to Angular 2

  • 2020-12-26 05:20:14
  • OfStack

The Angular team recently released the official version of Angular 1.5, which implements a major upgrade that will make it easier for developers still using the 1.ES3en version to transition to Angular 2 development.

Pete Bacon Darwin wrote in a blog post announcing the release that the goal of the release is "to improve the upgrade path for Angular 2. We have introduced a number of new features in this release that bring developers writing Angular 1 applications closer to the structure of their Angular 2 applications.

In this release, the new ES15en.component () helper method is the biggest change in the transition to Angular 2. By using this approach, developers no longer have to write directive in the traditional directive definition object style. If readers are already familiar with Angular 2, they should notice this similarity. In this article, the author presents an example of how to define a new component:


myModule.component('myComponent', {
template: '<h1>Hello {{ $ctrl.getFullName() }}</h1>',
bindings: { firstName: '<', lastName: '<' },
controller: function() {
this.getFullName = function() {
return this.firstName + ' ' + this.lastName;
};
}
});

Before component, developers often had to use directive or use controller for some scenarios. This is not to say that component will completely replace directive. For example, component cannot be used to operate DOM, and all component must be activated by custom HTML elements, not by element attributes. component as defined above can be used with the following code:


<my-component first-name="'Alan'" last-name="'Rickman'"></my-component>

The new component guidelines provide a more complete explanation of the differences between traditional directive and component.

One-way binding

Lifecycle hook

Bind to the required directive

transclusion with support for multiple slot

Default transclusion content

Developers who are currently using 1.4 can read the migration guide to see what changes are necessary for the migration, as 1 of these disruptive changes were introduced in 1.5.

Release 1.5 should be the biggest change in the foreseeable 1 period. When InfoQ asked Bacon Darwin what the 1.ES67en version was going to be, he had this answer:

We have not yet started planning the next release cycle for Angular 1. As we get closer to the Angular 2 release date, if we continue to work on Angular 1, we will try to make it as close to Angular 2 as possible. If you have to introduce disruptive changes in order to achieve this 1, you can expect 1.6. In the meantime, we will continue the development of Angular 1.5.ES75en version, offering bug fixes as well as a few minor features. In summary, this does not conflict with our goal of making Angular 1.X easier to migrate to Angular 2.

The new component router feature should be released later this week. Interested friends please pay attention to this site!


Related articles: