0
我正在研究nodejs應用程序,我們使用Ui路由器來實現單頁面應用程序,我創建了節點js中的控制器,它加載了包含角度腳本和庫的Layout,然後我試圖轉到throught我在UI路由器定義的路線,每個我得到了在控制檯中的錯誤表示"angular.js:8081 GET http://localhost:2405/Views/Partials/Know-me.html 404 (Not Found)"
我不能指定問題Ui路由器找不到Nodejs的視圖
這個時候是一些代碼:
控制器的NodeJS
app.get("/",function(req , res){
res.render("Template.ejs"); // this is the layout
});
個
佈局腳本:
<script src="http://code.angularjs.org/1.2.13/angular.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.8/angular-ui-router.min.js"></script>
<script src="../../angular_js/app_angular.js"></script>
和app_angular腳本:項目
var appmodule = angular.module('mainApp',[ui.router]);
appmodule.config(function($stateProvider , $urlRouterProvider , $locationProvider){
$urlRouterProvider.otherwise('/things');
$stateProvider
.state('me',{
url : '/me',
templateUrl : '/Views/Partials/Know-me.html'
})
.state('amir',{
url : '/amir',
templateUrl : '/Know-me-amir.html'
});
//$locationProvider.html5Mode(true);
});
結構:
- 查看
---共享
- --- Temaplte.ejs
---局部模板
----知識me.html
- 腳本
--- angular_js
---- angular_app.js
嘗試添加一個。在你的templateUrl的路徑的開始。 templateUrl:'./Know-me-amir.html'。如果它不起作用,你能告訴我們你的項目結構嗎? –
我添加了項目@AnassAnas的結構 –