0

I am learning Angularjs and Restangular. I am following this page http://www.ng-newsletter.com/posts/restangular.html

== app.js== 
angular.module('app', ['restangular']);

angular.module('app')
.controller('TestCtrl', ['$scope','Restangular',
  function($scope,Restangular) {
    this.product="gem";
  }]);

== index.html ==
<!DOCTYPE html>
<html ng-app="app">
  <head>
    <script type="text/javascript" src="js/angular.min.js"></script>
    <script type="text/javascript" src="js/restangular.min.js"></script>
    <script type="text/javascript" src="js/app.js"></script>
  </head>
  <body>
    <div ng-controller="TestCtrl as test">
        {{test.product}}
    </div>
  </body>
</html>

When i open index.html, it just opens {{test.product}}. But when i remove restangular references from app.js, it works fine. Paths to .js files are correct.

Please help me in getting this sorted.

rajya vardhan
  • 1,121
  • 4
  • 16
  • 29
  • 1
    Show the error message which is on your console. And you can use `console.log(angular.module('restangular'))` to check Restangular lib loaded or not. – Chen-Tsu Lin Sep 06 '14 at 18:08

1 Answers1

1

==Solution==

This stackoverflow answer told me that i should NOT be using minified version of angular.js as it doesn't show error in detail. I was getting this error:

Error: Failed to instantiate module restangular due to: '_' is undefined

From this answer i came to know that i was missing underscore/lodash which is a dependency of restangular. I included lodash in my html and everything worked fine then.

Community
  • 1
  • 1
rajya vardhan
  • 1,121
  • 4
  • 16
  • 29