2

i am trying to inject $http into directive controller like the following :

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) {  

         });
    ]};        
});

what is wrong with this injection ?

1 Answer 1

10

You have to respect the same order for your injections :

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

         });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.