Can';我们不能在不设置环境的情况下运行简单的Angular2代码吗?

Can';我们不能在不设置环境的情况下运行简单的Angular2代码吗?,angular,angular2-routing,angular2-template,Angular,Angular2 Routing,Angular2 Template,我只想在不设置环境的情况下运行下面提到的简单代码,但它将错误显示为“app.js:5 UncaughtTypeError:angular.ComponentAnnotation不是app.js:5的构造函数” 这是我的index.html代码 <!doctype html> <html> <head> <title>My first App</title> <link rel="stylesheet" src=

我只想在不设置环境的情况下运行下面提到的简单代码,但它将错误显示为“app.js:5 UncaughtTypeError:angular.ComponentAnnotation不是app.js:5的构造函数”

这是我的index.html代码

<!doctype html>
 <html>
 <head>
    <title>My first App</title>
    <link rel="stylesheet" src="css/main.css" />    
    <script src="https://code.angularjs.org/2.0.0-alpha.20/angular2.sfx.dev.js"></script>
    <script src="js/app.js"></script>
</head>

<body>
    <mynewTag></mynewTag>
</body>
</html>

我的第一个应用程序
下面是app.js的代码

function firstApp(){}
firstApp.annotations = [
new angular.ComponentAnnotation({

    selector: "mynewTag"
}), 
new angular.viewAnnotation({
    template: "<div><h1>Arun</h1></div>"
})
];
document.addEventListener("DOMContentLoaded", function(){
angular.bootstrap(firstApp);
})
函数firstApp(){}
firstApp.annotations=[
新的angular.ComponentAnnotation({
选择器:“mynewTag”
}), 
新的angular.viewAnnotation({
模板:“Arun”
})
];
document.addEventListener(“DOMContentLoaded”,function()){
角度引导(firstApp);
})

不知道为什么要使用过时的Angular版本,但请看下面的文章(),它使用纯JavaScript和Angular

语法随着诸如
ng.core.Component等全局变量的使用而改变

您可以按照post所示安装节点模块,也可以使用CDN URL,例如:


运行简单的Angular2程序需要安装Node.js和NPM吗?不需要,脚本部分的URL可以由cdn中的NPM替换,例如
。确保版本匹配。嗨,我也这么做了,但仍然不起作用。你能帮忙吗?或者你能给我发送正确的代码来运行上述要求吗?你能创建一个plunkr,我可以看看。问题解决了,我没有安装nodejs和typescript。