2015-10-23 72 views
0

這是我的script.js代碼:

var app = angular.module('starter', []) 

app.provider('RouteHelpers', function() { 

    this.basepath = function (uri) { 
     return 'app/views/' + uri; 
    }; 

    this.$get = function() { 
    }; 

}); 

app.config(function (RouteHelpers) { 
    console.log('Never gets here'); 
}); 

這是index.html的:

<!DOCTYPE html> 
<html> 
    <head> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <title></title> 

    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> 


<script src="angular.min.js"></script> 


    <script src="script.js"></script> 
    </head> 

    <body ng-app='starter'> 


    </body> 
</html> 

而且我得到這個錯誤在我的瀏覽器中:https://tinyurl.com/nbareaa 有人知道這段代碼有什麼問題嗎?

回答

1

您已經創建了一個提供者,如果你嘗試並注入到你的配置功能,您必須附加Provider的供應商名稱的末尾,例如,這意味着:

app.config(function(RouteHelpersProvider){ 

}); 

你所得到的錯誤,因爲它無法找到給定的噴油器。您可以在供應商配方下閱讀更多here

相關問題