2014-06-12 30 views
0

我已經寫了如下一個簡單的角的js應用:在angularjs應用獲得更友好的錯誤消息

angular.module("myApp",['ngRoute']) 
.config(['$routeProvider',function($routeProvider){ 

    $routeProvider 
    .when('/',{ 
    name:'route1', 
    controller:'Route1Ctrl', 
    template:'partials/route1.tpl.html' 
    }) 

.otherwise({redirectTo:'/'}); 

}]) 

.controller('Route1Ctrl',['$scope',function($scope){ 


}}); 

的應用程序加載失敗,我也可以在Chrome控制檯中看到的唯一錯誤消息:

Uncaught objet 

我該怎麼做才能獲得更多可用的錯誤消息?

+0

包住整個事情在'嘗試{..your代碼在這裏..}趕上(E){警報(「對不起戴夫,恐怕我不能那樣做。「);出口(); }' – usr2564301

+0

錯誤原來是角度無法找到myApp模塊,因爲路徑中存在拼寫錯誤。它仍然有助於獲得更友善的錯誤消息。 Try..catch塊沒有幫助導致JavaScript無法獲得這些行.. – runtimeZero

+0

@JamesHans,這是[已知問題](https://github.com/angular/angular.js/issues/5568)與鉻瀏覽器。 – Mike

回答

0

代替模板:您必須使用templateUrl

+0

我修復了那麼長的背部..但那不是重點..要獲得更好的錯誤信息.. thx雖然 – runtimeZero

相關問題