Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I want to pass the data of the function PhoneList() to the UI-Router controller function to the state 'phonedescription'.

JS:

var myApp = angular.module('myApp', ["ui.router"]);

myApp.config(function($stateProvider, $urlRouterProvider){

  // For any unmatched url, send to /route1
  $urlRouterProvider.otherwise("/phone")

  $stateProvider
    .state('phone', {
        url: "/phone",
        templateUrl: "index.html"
    })
    .state('phonedescription', {
          url: "/description",
          templateUrl: "description.html",
          controller: function($scope){
            //Want to access the angular object to pass the attributes to this controller


          }
    }
});

function PhoneList($scope, $http, $templateCache)
{
    $scope.list = function() {
      $scope.phones = //get data from backend
    }
    $scope.list();
};
share|improve this question
add comment

1 Answer

It appears that you are defining PhoneList as a loose function outside of the angular framework. Look into using a service instead. You can then inject that service into your phonedescription controller.

share|improve this answer
add comment

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.