0

How can I use [ngRoute] and [ngResource] at the same time.

Not sure if I am right but I've got my code looking something like this

var app = angular.module("myApp",  ["ngRoute"],["ngResources"]);

But this doesn't work

Originally it is something like this

 var app = angular.module("myApp",  ["ngRoute"]);

I want to add ngResource to add the API restful post on my site.

Any help or suggestions please. Thank

georgeawg
  • 48,608
  • 13
  • 72
  • 95

2 Answers2

3

Try

var app = angular.module("myApp",  ["ngRoute","ngResources"]);

the second argument of angular.module is an array, and you are passing two arrays. Rather, pass every module as a string in the same array. They are not directives but modules

Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104
2

First thing they aren't directive, they are angular module. You should mention all the dependencies inside the array itself, it contains collection of all the dependent modules.

var app = angular.module("myApp", [
   "ngRoute",
   "ngResource"
   //,...other dependent module should be kept in array as comma separated.
]);
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299