angularjsrestangular

RestAngular - Injector module error


I'm totally new to the Restangular and trying to learn it by implementing a simple application by calling a webapi. I'm able to call this service with simple $http service and getting the correct response.

The code I have written is as below. I have googled the issue to find the solution but no like.

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

myApp.config(function (RestangularProvider) {
    var newBaseUrl = "";

        newBaseUrl = 'http://localhost:37103/api/'

    RestangularProvider.setBaseUrl(newBaseUrl);
})

myApp.controller("myCtrl", function ($scope, Restangular) {
    $scope.data = "Default Value"
    $scope.data = Restangular.one("employee").get();
})

The error which I'm getting on chromes console is as below

 angular.min.js:6 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/$injector/modulerr?p0=myApp&p1=Error%3A%2…0Bc%20(http%3A%2F%2Flocalhost%3A37103%2FSource%2Fangular.min.js%3A21%3A179)

The above error is clickable and it says may be the file is mot included. But I have included the restangular.js file and I could see it getting loaded in the network tab.

Thanks!


Solution

  • For this issue I found something was wrong in the restangular.js file which I downloaded. I replaced it with the cdn tag cdnjs.cloudflare.com/ajax/libs/restangular/1.5.1/restangular‌​.js and it worked. Its very strange.