0

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();
};

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.