當我嘗試使用角度運行本地項目時,我從Chrome獲得404狀態。我不確定問題所在,我已經嘗試了類似問題的建議答案。
這是我的指令文件:
'use strict';
/**
* @ngdoc directive
* @name stockDogApp.directive:stkWatchlistPanel
* @description
* # stkWatchlistPanel
*/
angular.module('stockDogApp')
.directive('stkWatchlistPanel', function ($location, $modal, WatchlistService) {
return {
templateUrl: 'views/templates/watchlist-panel.html',
restrict: 'E',
scope : {},
link: function($scope){
$scope.watchlist = {};
var addListModal = $modal({
scope : $scope,
template: 'views/templates/addlist-modal.html',
show : false
});
$scope.watchlists = WatchlistService.query();
$scope.showModal = function(){
addListModal.$promise.then(addListModal.show);
};
$scope.createList = function(){
WatchlistService.save($scope.watchlist);
addListModal.hide();
$scope.watchlist = {};
};
$scope.deleteList = function(list){
WatchlistService.remove(list);
$location.path('/');
};
}
};
});
這是我的「應用程序」的樹狀視圖文件夾
|-- 404.html
|-- favicon.ico
|-- images
| `-- yeoman.png
|-- index.html
|-- robots.txt
|-- scripts
| |-- app.js
| |-- controllers
| |-- directives
| | `-- stk-watchlist-panel.js
| `-- services
| `-- watchlist-service.js
|-- styles
| `-- main.css
`-- views
`-- templates
|-- addlist-modal.html
`-- watchlist‐panel.html
我得到一個頁面沒有找到錯誤,當我加載的index.html在我的控制檯。
Error: [$compile:tpload] Failed to load template: views/templates/watchlist-panel.html (HTTP status: 404 Not Found)
http://errors.angularjs.org/1.4.4/$compile/tpload?p0=views%2Ftemplates%2Fwatchlist-panel.html&p1=404&p2=Not%20Found
我也嘗試從根文件夾輸入完整路徑,但它仍然沒有檢測到頁面。
我不確定這是否是原因,但看看Chrome開發人員工具顯示源選項卡沒有應用程序文件夾(它只顯示'bower_components','腳本','樣式'和index.html的
**更新**
看來,這角度無法看到的唯一文件夾是在應用程序的意見文件夾中。我不能確定問題所在。莫不是有繁重的一個問題?
ngtemplates: {
dist: {
options: {
module: 'stockDogApp',
htmlmin: '<%= htmlmin.dist.options %>',
usemin: 'scripts/scripts.js'
},
cwd: '<%= yeoman.app %>',
src: 'views/{,*/}*.html',
dest: '.tmp/templateCache.js'
}
},
這是否運行縮小的代碼?或者只是運行「咕嚕咕嚕」? –
你解決了嗎,因爲如果你這樣做,我卡在它 –
只是重新編寫了整個事情..工作正常,然後出於某種奇怪的原因 – Kannaj