2015-10-27 53 views
0
<!DOCTYPE html> 

<html ng-app="myApp"> 

    <head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 

    <script src="js/app.js"></script> 
    <script src="node_modules/angular/angular.min.js"></script> 
    <script src="node_modules/angular-ui-router/release/angular-ui-router.min.js"></script> 

    </head> 

    <body> 
     <input type="text" ng-model="name" /> {{name}} 
    </body> 

</html> 

我上面有这段代码。但是,当我在http-server {{name}}上运行它时,不会显示放置在输入字段中的任何内容,而会显示“{{name}}”。AngularJS未成功导入

我错误地导入了angularjs?

我的文件系统目前看起来像

的index.html

JS - > app.js

node_modules - >角 - > angular.min.js

等等。

谢谢!

+6

角度需要被加载** **你的'app.js'。 – Claies

+0

好悲痛。谢谢你告诉我。我不知道脚本加载的顺序很重要! – tryingtolearn

回答

0

我猜想,因为您正在使用节点,所以node_modules不会暴露于公用文件夹或作为静态文件。

documentation

http-server [path] [options] 

[path] defaults to ./public if the folder exists, and ./ otherwise. 

你有一个公用文件夹?如果是这样,那么我想这就是为什么。

0

正如Claies上面所说:

角需要你app.js之前之前加载

<script src="node_modules/angular/angular.min.js"></script> 
<script src="js/app.js>