2015-07-12 39 views
0

用下面的代碼,我看到我的按鈕(角1.3.15,DevExtreme 15.1.4)錯誤時分配控制器div的

HTML:

<!DOCTYPE html> 
<html ng-app="myApp"> 
<head> 
    <meta charset="utf-8"> 
    <title>Testing</title>  
    <link href="Content/dx.common.css" rel="stylesheet" /> 
    <link href="Content/dx.light.css" rel="stylesheet" />  
</head> 
<body>  
    <script src="/Scripts/jquery-1.11.3.min.js"></script> 
    <script src="/Scripts/jquery.globalize/globalize.js"></script>  
    <script src="/Scripts/angular.min.js"></script> 
    <script src="/Scripts/angular-sanitize.min.js"></script> 
    <script src="/Scripts/angular-ui-router.min.js"></script>  
    <script src="/Scripts/dx.webappjs.js"></script>  
    <script src="/app/app.js"></script>  

    <div ng-controller="myCtrl"> 
     <div dx-button="{text: 'Test Button'}"></div> 
    </div>  

</body> 
</html> 

app.js文件:

var myApp = angular.module('myApp', ['dx']); 

(function() { 
    angular.module('myApp') 
     .controller('myCtrl', ['$scope','dx', myCtrl]); 

    function myCtrl($scope, dx) { 
     var vm = this; 
    } 
}()); 

我看到的按鈕,沒有錯誤,但是當我在div添加控制器:

<div ng-controller="myCtrl"> 
    <div dx-button="{text: 'Test Button'}"></div> 
</div> 

我得到這個錯誤: 錯誤:[$注射器:unpr] http://errors.angularjs.org/1.3.15/ $注射器/ unpr P0 = dxProvider%20%3 C-%20DX%20%3 C-%20myCtrl R/< http://localhost:51314/Scripts/angular.min.js:6:417 @

+0

腳本引用不應該放在頭部分嗎? –

回答

-1

您正試圖將dx模塊注入您的myCtrl控制器。嘗試刪除它:

var myApp = angular.module('myApp', ['dx']); 

(function() { 
    angular.module('myApp') 
     .controller('myCtrl', ['$scope', myCtrl]); 

    function myCtrl($scope) { 
     var vm = this; 
    } 
}()); 

爲了將來的參考,以下在Angular錯誤中給出的鏈接可以幫助揭示這些問題。