[Angular 2] 8. Better ES5 Code

本文介绍了一个使用 AngularJS 2.0 Alpha 版本构建的简单 Web 应用实例。该应用包含一个名为 Egghead 的组件,其内部又包含另一个名为 Note 的子组件。通过此实例,读者可以了解 AngularJS 2.0 的基本结构及其组件化开发方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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);
});

 

转载于:https://www.cnblogs.com/Answer1215/p/4758545.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值