Home > Web Front-end > JS Tutorial > body text

Angular releases official version 1.5, focusing on the transition to Angular 2_AngularJS

WBOY
Release: 2016-05-16 15:15:04
Original
1131 people have browsed it

The Angular team recently released the official version of Angular 1.5, which has achieved a major upgrade. It allows developers who are still using version 1.X to more easily transition to Angular 2 development.

Pete Bacon Darwin wrote in a blog post announcing the release that the purpose of this release is to "improve the upgrade path for Angular 2. We have introduced some new features in this release to allow developers to write Angular 1 applications are closer to the structure applied in Angular 2. ”

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

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

Before the emergence of components, developers usually could only use directives, or achieve certain scenarios through unconventional use of controllers. But this does not mean that components will completely replace the role of directives. For example, components cannot be used to operate the DOM, and all components must be activated through custom HTML elements, and triggering through element attributes is not supported. The component defined in the above way can be used through the following code:

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

The new component guide provides a more complete explanation of the differences between traditional directives and components.

One-way binding

Life cycle hook

Bind to required directive

Supports transclusion for multiple slots

Default transclusion content

Developers currently using version 1.4 can read the Migration Guide to learn what necessary changes are required when migrating, as some breaking changes were introduced in version 1.5.

In the foreseeable period of time, version 1.5 should be the biggest change. When InfoQ asked Bacon Darwin where version 1.X will go, here’s what he said:

We haven’t started planning for Angular 1’s next release cycle yet. Since the official release date of Angular 2 is getting closer, if we continue to develop Angular 1, we will try to make it closer to Angular 2. If breaking changes have to be introduced to achieve this, then version 1.6 can be expected. At the same time, we will continue the development of Angular 1.5.x version, providing bug fixes and some smaller features. In short, 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 the Script House website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!