【发布时间】:2016-06-28 06:55:18
【问题描述】:
我想做的是非常基本的。我想使用 npm 安装 AngularJS v1.5.x,然后让我在我的应用程序中使用它。我看到的所有教程都只是从 angularjs.org 下载 Angular 版本,然后将其包含在 index.html 的 <script></script> 标签中。但我想使用 npm 安装 AngularJS,然后让我可以在我的 index.html 中使用它,就像真正的开发人员可能会做的那样!
这是我运行的命令。
$ npm init
$ npm install angular@1.5.7 --save
npm-angular-test@1.0.0 /Users/theDanOtto/Sites/Playground/npm-angular-test
└── angular@1.5.7
这是我的基本package.json
{
"name": "npm-angular-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"angular": "^1.5.7"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
我创建了一个index.js,但我将其留空。然后我在我的index.html 中添加了一个 src 标签以包含index.js。
<!DOCTYPE html>
<html ng-app>
<head>
<title>Html</title>
<script src="index.js"></script>
</head>
<body>
<p>My first expression: {{ 5 + 5 }}</p>
</body>
</html>
我的表达式只是写{{ 5 + 5 }} 而不是10。我哪里错了?
【问题讨论】:
标签: javascript angularjs npm