Pierre
Pierre

Reputation: 33

Conflict between a Directive and a Service($resource) with AngularJS

I'm newbie in angularJS world and I probably misunderstand something.

My app use controllers, directives and services, all run perfectly untill I use a service with $resource, then there is a "conflict" or something else wrong.

Working directive :

myApp.directive('components', function(){
    return function(params){
        [...]
    }
});

Working service :

myApp.factory('myFactory', function(){
    return{
        [...]
    }
});

Service that cause the trouble :

angular.module('myApp', ['ngResource']).factory('resourceFactory', function($resource){
    return{
        [...]
    }
});

There is no error in the console, the service with $resource works but the directive seems not executed.

Can you help me ?

Upvotes: 3

Views: 409

Answers (1)

Tosh
Tosh

Reputation: 36030

try to define myApp in following way.

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

then define service/directive/controller on it.

myApp.controller(...)
myApp.directive(...)
myApp.factory(...)

Upvotes: 3

Related Questions