Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

Im try to use Oboe.Js and Angular.Js together

Here is my sample code which is working correctly..

angular.module('myApp', ['ng-oboe'])
 .config(function (oboeProvider) {
             /* If we were so inclined, we could change the oboe defaults here - headers, etc. */
             // oboeProvider.defaults = {};
     })
 .controller('myCtrl', function ($scope, oboe) {
                $scope.test = "Yo.";
                $scope.items = [];

                oboe.get('http://localhost:4243/containers/f78257b77b21/stats')
                        .start(function (data, etc) {
                        })
                        .node('!', function (value) {   
                        })
                        .done(function (value) {
                                console.log("It works! ", value.read);
                                $scope.items.push(value);
                        })
                        .fail(function (error) {
                                console.log("Error: ", error);
                        });
        });

But when I try to use these code with my actual project controller. I'm getting this error. I can't figure out Why I'm getting this.

Error : TypeError: Cannot read property 'get' of undefined

module.js

angular.module('RDash', ['ui.bootstrap', 'ui.router', 'ngCookies','ng-oboe'])
  .config(function (oboeProvider) {
      /* If we were so inclined, we could change the oboe defaults here - headers, etc. */
      // oboeProvider.defaults = {};
  });

stats-ctrl.js

  angular
  .module('RDash')
  .controller('StatsCtrl', ['$scope', '$stateParams', StatsCtrl]);

  function StatsCtrl($scope, $stateParams, oboe) {

    var id = $stateParams.id;

    $scope.myData = [];

    $scope.items = [];

    console.log('http://localhost:4243/containers/' + id + '/stats');

  oboe.get('http://localhost:4243/containers/' + id + '/stats')
        .start(function (data, etc) {
            console.log("Dude! We're goin'!", data, etc);
        })
        .node('!', function (value) {

        })
        .done(function (value) {
            console.log("It works! ", value.read);
        })
        .fail(function (error) {
            console.log("Error: ", error);
        });
}
share|improve this question
    
It doesn't look like you are injecting oboe in your controller setup. – Matthew Green Jan 4 at 20:22
    
@MatthewGreen sorry, I'm forget to add module.js file. I already injected 'ng-oboe' my module.js file. Do I need to injecting in controller file again ? – Erol Guzoğlu Jan 4 at 20:28
    
I'm not talking about your module, I'm talking about the controller. You have $scope, $stateParams but no oboe. – Matthew Green Jan 4 at 20:29
    
Oh okay! Thanks! It escaped me! @MatthewGreen – Erol Guzoğlu Jan 4 at 20:36
up vote 2 down vote accepted

Inside your controller function you have obe factory has no value(undefined), because it haven't been injected inside DI array.

angular
  .module('RDash')
  .controller('StatsCtrl', ['$scope', '$stateParams', 'obe', StatsCtrl]); //<-inject obe here
      function StatsCtrl($scope, $stateParams, oboe) {
share|improve this answer
    
downvoter my answer were wrong because the question is highly edited.. – Pankaj Parkar Jan 4 at 20:28
    
yea, Im so sorry about that. It's my fault :( – Erol Guzoğlu Jan 4 at 20:33
    
That's working! Thanks! – Erol Guzoğlu Jan 4 at 20:36
    
@ErolGuzoğlu Glad to help you..Thanks :) – Pankaj Parkar Jan 4 at 20:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.