我第一次尝试这个角度应用程序。我根据webstorm和bower组件进行了设置,并在webstorm中安装了angularjs包
我的AngularJS应用程序 - > < /脚本> - > myapp = angular.module('myapp',[]);
</script>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div ng-view></div>
<div>Angular seed app: v<span app-version></span></div>
<!-- actual angular code bloack in div -->
<div id="main" ng-app = "app">
<nav class = "{{active}}" ng-click="$event.preventDefault">
<a href="#" class ="home" ng-click="active='home'">Home</a>
<a href="#" class = "projects" ng-click="active='projects">Projects</a>
<a href="#" class="services" ng-click="active='services'">services</a>
<a href="#" class="contact" ng-click="active='contact'">Contact</a>
<p ng-hide="active">Please click a menu item</p>
<p ng-show="active">you choose<b> {{active}}</b></p>
</nav>
</div>
<!-- <script src="bower_components/angular/angular.js"></script>-->
<!-- <script src="bower_components/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="view1/view1.js"></script>
<script src="view2/view2.js"></script>
<script src="components/version/version.js"></script>
<script src="components/version/version-directive.js"></script>
<script src="components/version/interpolate-filter.js"></script>-->
</body>`enter code here`
</html>
答案 0 :(得分:0)
纳克应用内=&#34; MyApp的&#34;应该放在身体里或所有角元标记都在其中,在你的情况下,正如你所看到的那样是正文。
同样在ng-app中,您应该使用与模块声明中完全相同的名称。
angular.module([MODULE_NAME], []);
答案 1 :(得分:0)
只需修改您的HTML:
<body ng-app="myapp">
而不是
<div id="main" ng-app = "app">
必须将 ng-app
指令放在站点的顶部,并使用您在模块中声明的名称。此外,如果您在代码示例<div ng-view></div>
中ng-app
之外ng-view
Handler.post()
将不起作用。