2015-08-23 195 views
-1

未能實例化模塊myApp我正在嘗試第一次使用這個角度應用程序。我做了一個設定爲每webstorm和涼亭的部件,並安裝angularjs包裝webstorm

我AngularJS應用 - > </SCRIPT> - > 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

NG-應用=「MYAPP」應該是在人體或地方,所有的角meta標籤在其內部,你的情況的身體,你看到的是當前外。

同樣在ng-app中,您應該放置與您在模塊聲明中放置的名稱完全相同的名稱。

angular.module([MODULE_NAME], []); 
0

只需修改HTML這樣的:

<body ng-app="myapp"> 

,而不是

<div id="main" ng-app = "app"> 

ng-app指令必須放置在您的網站上,並採取你在聲明的名稱該模塊。此外,如果你讓<div ng-view></div>以外的ng-app像你在你的代碼樣本ng-view不會工作。

+0

是那個答案適合您的需求? – Freezystem

相關問題