On the Polymer Getting Started page, we see an example of Polymer in action:(在Polymer Getting Started页面上,我们看到Polymer的实例:)
<html>
<head>
<!-- 1. Shim missing platform features -->
<script src="polymer-all/platform/platform.js"></script>
<!-- 2. Load a component -->
<link rel="import" href="x-foo.html">
</head>
<body>
<!-- 3. Declare the component by its tag. -->
<x-foo></x-foo>
</body>
</html>
What you will notice is <x-foo></x-foo>
being defined by platform.js
and x-foo.html
.(您将注意到由platform.js
和x-foo.html
定义的<x-foo></x-foo>
。)
It seems like this is the equivalent to a directive module in AngularJS:(看起来这相当于AngularJS中的指令模块:)
angular.module('xfoo', [])
.controller('X-Foo', ['$scope',function($scope) {
$scope.text = 'hey hey!';
})
.directive('x-foo', function() {
return {
restrict: 'EA',
replace: true,
controller: 'X-Foo',
templateUrl: '/views/x-foo.html',
link: function(scope, controller) {
}
};
});
What is the difference between the two?(两者有什么区别?)
What problems does Polymer solve that AngularJS has not or will not?(Polymer解决AngularJS没有或不会有什么问题?)
Are there plans to tie Polymer in with AngularJS in the future?(是否有计划在未来将Polymer与AngularJS联系起来?)
ask by Dan Kanze translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…