2016-02-27 53 views
2

我想使用UI路由器,但我無法打開第一頁的視圖不知道爲什麼它不會顯示模板。它只會顯示index.html元素。幫助將不勝感激我是新來的,你需要參考app.js腳本參考角AngularJs UIRouting

<!DOCTYPE html> 
<html lang="en"> 
<head> 

<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<title>Webstie Designing</title> 
<!-- Angular Scripts --> 
<script src="js/angular.min.js"></script> 
<script src ="js/angular-resource.js"></script> 
<script src="js/angular-mocks.js"></script> 
<script src="js/angular-ui-router.js"></script> 
<!-- Application Scripts--> 
<script type="text/javascript">"app/app.js"</script> 
</head> 
<body id="page-top" ng-app="portfolio"> 

<nav id="mainNav" class="navbar navbar-default navbar-fixed-top"> 
    <div class="container-fluid"> 
     <!-- Brand and toggle get grouped for better mobile display --> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
       <span class="sr-only">Toggle navigation</span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
       <span class="icon-bar"></span> 
      </button> 
      <a class="navbar-brand page-scroll" href="#/">Web Designing</a> 
     </div> 

     <!-- Collect the nav links, forms, and other content for toggling --> 
     <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
      <ul class="nav navbar-nav navbar-right"> 
       <li> 
        <a class="page-scroll" href="#about">About</a> 
       </li> 
       <li> 
        <a class="page-scroll" href="#services">Services</a> 
       </li> 
       <li> 
        <a class="page-scroll" href="#portfolio">Portfolio</a> 
       </li> 
       <li> 
        <a class="page-scroll" href="#contact">Contact</a> 
       </li> 
      </ul> 
     </div> 
     <!-- /.navbar-collapse --> 
    </div> 
    <!-- /.container-fluid --> 
</nav> 

<div class="container"> 
    <div ui-view></div> 
</div> 




(function(){ 
      "use strict"; 
      var app = angular.module("portfolio",["ui.router"]); 
      app.config(["$stateProvider","$urlRouterProvider", 
       function("$stateProvider","$urlRouterProvider"){ 
        $urlRouterProvider.otherwise('/'); 
         $stateProvider 
          .state("home",{ 
            url:"/", 
            templateUrl:"app/Intro.html" 
          }) 
        }] 
      ); 
}()); 
+0

你收到任何異常? –

+0

我不使用IDE,所以不知道:( –

+0

你的文件是否位於正確的位置?Intro.html確實在應用程序文件夾下? –

回答

1

第一件事正確地使可portfolio模塊ng-app

<script type="text/javascript" src="app/app.js"></script> 

,而不是

<script type="text/javascript">"app/app.js"</script> 
+0

沒有用的還是:( –

+0

@NoumanSaif控制檯中的任何錯誤 –

+0

不要使用控制檯,您可以檢查出來,請我說了神奇的詞,:??d –