こんにちは私はbillerModelという名前のモデルと、billersの変数を持つ解決策を持つルートを作成しました。今私は取得し、私のコントローラ内でこの変数を割り当てたいが、私はこのbillerData不明プロバイダエラーを取得します。以下は、ルートの私のコードです:変数を取得してコントローラに渡す
以下app.config(["$routeProvider", "$httpProvider",'$locationProvider',function($routeProvider, $httpProvider, $locationProvider) {
$routeProvider
.when("/billers", {
templateUrl: 'admin/billers/index.html',
controller: 'billerController',
resolve: {
billerData: function(billerModel) {
return billerModel.getData();
}
}
});
は、モデル以下
app.factory('billerModel', ['$http', '$cookies', function($http, $cookies) {
return {
getData: function() {
return $http({
method: 'GET',
url: 'billers'
});
}
}
}]);
ための私のコードである私もしようとした私にエラーを与える私のコントローラのコード
app.controller('billerController', ['$scope', 'billerData',
function($scope, billerData){
$scope.billers = billerData;
}]);
です私のビューからng-controllerを削除しますが、これを行うと未知の変数のエラーが発生します
<div style="text-align: left;" ng-controller="billerController">
{{ billers }}
</div>
以下は
あなたが変更してみてくださいでしjsfiddleですが、私はそれを使用する方法の慣れていないんだが、基本的な構造は、ここで https://jsfiddle.net/bd06cctd/1/
あなたは工場 'billerModel'を作成します。しかし、コントローラ 'billerData'に注入してみてください。 'billerModel'にインジェクションを変更してください。 –