What is the difference between Polymer elements and AngularJS directives?

后端 未结 10 1734
清歌不尽
清歌不尽 2020-12-02 03:11

On the Polymer Getting Started page, we see an example of Polymer in action:


  
             


        
10条回答
  •  生来不讨喜
    2020-12-02 03:40

    What is the difference between the two?

    To a user: Not much. You can build awesome apps with both.

    To a developer: They use way different syntax so either solution has a fairly steep learning curve. Angular has been around longer and has a HUGE community so you'd be hard pressed to find problems that haven't been solved.

    To an architect: Very different. Angular is an application framework responsible for all aspects of your life. It even has directives vertically integrated in case you want component like features. Polymer on the other hand is more like pay-as-you-go. You want a modal, sure thing, you want an interactive widget, no problem, you want route handling, we can do that to. Polymer is also more portable in that Angular requires an Angular app to reuse directives. The idea with Polymer is be more moduler and will work in other apps, even Angular apps.

    What problems does Polymer solve that AngularJS has not or will not?

    Polymer is an approach to head towards taking advantage of the new web components standards. If features like custom elements, Shadow DOM, and HTML imports are supported locally, it would be foolish not to take advantage of them. Currently most web component features are not widely supported (current status) so Polymer acts as shim or a bridge. Kinda like a polyfill (in fact it does use polyfills).

    Are there plans to tie Polymer in with AngularJS in the future?

    We have been using Angular and Polymer together for over a year. Part of the decision to do this was based on promises made directly by the Polymer team to us that interoperability be there. We have given up on that idea. We are now moving towards using only Polymer.

    To do it over again we probably would not have made the move to use Polymer at all, instead wait for it to mature. That being said Polymer has it's pros (some quite good) and cons (some of which are quite frustrating) but I think that is a discussion for another thread.

提交回复
热议问题