[Angular 2] 8. Better ES5 Code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JS Bin</title>
    <script src="https://code.angularjs.org/2.0.0-alpha.28/angular2.sfx.dev.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>

<egghead></egghead>
<script src="app.js"></script>
</body>
</html>

 

var Note = angular
    .Component({
        selector: 'note'
    })
    .View({
        template: '<h3>World</h3>'
    })
    .Class({
        constructor: function() {

        }
    });

var Egghead = angular
    .Component({
        selector: 'egghead'
    })
    .View({
        template: '<div><h1>Hello</h1><note></note></div>',
        directives: [Note]
    })
    .Class({
        constructor: function() {

        }
    });

document.addEventListener("DOMContentLoaded", function() {
    angular.bootstrap(Egghead);
});

 

posted @ 2015-08-25 20:37  Zhentiw  阅读(193)  评论(0编辑  收藏  举报