- Switching to Angular(Third Edition)
- Minko Gechev
- 347字
- 2021-07-02 15:23:30
Web components
The first public draft of web components was published on May 22, 2012, about 3 years after the release of AngularJS. As mentioned, the web components standard allows us to create custom elements and attach behavior to them. It sounds familiar because we've already used a similar concept in the development of the user interface with AngularJS. Web components sound like an alternative to Angular directives; however, they have a more intuitive API and built-in browser support. They introduced a few other benefits, such as better encapsulation, which is very important, for example, in handling CSS-style collisions.
A possible strategy for adding web components support in AngularJS is to change the directives implementation and introduce primitives of the new standard in the DOM compiler. As Angular developers, we know how powerful and complex the directives API is. It includes a lot of properties, such as postLink, preLink, compile, restrict, scope, and controller, and of course, our favorite transclude. Approved as standard, web components will be implemented on a much lower level in the browsers, which introduces plenty of benefits, such as better performance and native API.
During the implementation of web components, a lot of web specialists met with the same problems the AngularJS team did when developing the directives API, and came up with similar ideas. Good design decisions behind web components include the content element, which deals with the infamous transclusion problem in AngularJS. Since both the directives API and web components solve similar problems in different ways, keeping the directives API on top of web components would have been redundant and added unnecessary complexity. This is why the Angular core team decided to start from the beginning by building a framework compatible with web components and taking full advantage of the new standard. Web components involve new features; some of them are not yet implemented by all browsers. In case our application is run in a browser which does not support any of these features natively, Angular emulates them. An example for this is the content element polyfilled with the ng-content directive.
- 深度實(shí)踐OpenStack:基于Python的OpenStack組件開(kāi)發(fā)
- 自己動(dòng)手寫搜索引擎
- Android開(kāi)發(fā)精要
- 大學(xué)計(jì)算機(jī)基礎(chǔ)實(shí)驗(yàn)教程
- Reactive Programming with Swift
- 數(shù)據(jù)庫(kù)系統(tǒng)原理及MySQL應(yīng)用教程
- C#程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- Visual Basic程序設(shè)計(jì)教程
- 愛(ài)上micro:bit
- Geospatial Development By Example with Python
- Python入門很輕松(微課超值版)
- Bootstrap for Rails
- ASP.NET求職寶典
- Flink技術(shù)內(nèi)幕:架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理
- 零基礎(chǔ)學(xué)Java第2版