2015-06-06 2 views
2

я пытаюсь внедрить $ HTTP в контроллер директивы как следующее:

JS

app.direcitve('customDirecitve',function(){ 
    return : 'E', 
    scope : { 
     url : "@", 
     urlParams : "@" 
    } , 
    controller : ['$scope', '$http', function($scope, $element, $attrs, $transclude,$http) { 
     $http.post($scope.url,$scope.urlParams).success(function (data) { 

     }); 
    ]};   
}); 

, что случилось с этой инъекции?

ответ

10

Вы должны соблюдать тот же порядок для инъекций:

controller : ['$scope','$element', '$attrs', '$transclude', '$http', function($scope, $element, $attrs, $transclude, $http) { 
     $http.post($scope.url,$scope.urlParams).success(function (data) { 

     }); 
+0

Благодаря @Marius, что это было :) – sisimh

Смежные вопросы