angular 2 beta ng不适用于javascript

时间:2016-01-01 07:20:27

标签: javascript angular angular2-directives

我是角度2.0.0测试版的新手,并在javascript中开发。我无法使ngFor指令工作。我有一个组件list.component.js,一个boot.js文件和index.html。我不知道自己做错了什么。以下是代码:

list.component.js

function(app) {
  app.ListComponent = ng.core
    .Component({
        selector: 'list'
    })
    .View({
        template:'<ul>'
        +'<li *ng-for="#name of names" >{{name}}</li>'
        +'</ul>'
        +'<p *ng-if="names.length > 3">You have many friends!</p>',
        directives: [angular.NgFor]
    })
    .Class({
        constructor: function() {
            this.names = ["Aarav", "Martín", "Shannon", "Ariana", "Kai"];
        }
    });
})(window.app || (window.app = {}));

boot.js

(function(app) {
  document.addEventListener('DOMContentLoaded', function() {
    ng.platform.browser.bootstrap(app.ListComponent);
  });
})(window.app || (window.app = {}));

的index.html

<html>
  <head>
    <title>Angular 2 Example</title>

    <!-- 1. Load libraries -->
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
    <script src="node_modules/angular2/bundles/angular2-all.umd.js"></script>

    <!-- 2. Load our 'modules' -->
    <script src='app/list.component.js'></script>
    <script src='app/boot.js'></script>

  </head>

  <!-- 3. Display the application -->
  <body>
    <list>loading...</list>
  </body>

</html>

我所看到的只是“加载......&#39;。

对于angular.io上的javascript,angular2 beta似乎也有限。如果有人可以参考一些关于javascript的角度2 beta的好教程,那将非常有帮助。感谢。

0 个答案:

没有答案