javascript - How to call function of one controller from other controller in angularjs? -


i want call listing function of testcontroller usercontroller. mark(//) place want call function in following code. doing in angularjs

function usercontroller($scope, $http) {                  $scope.signup = function() {                      $http.post('<?php echo site_url('angularjs/addtotable'); ?>', {'uname': $scope.username, 'pswd': $scope.userpassword, 'email': $scope.useremail}                     ).success(function(data, status, headers, config) {                          // here want call listing function of testcontroller ...                     });                 }     }     function testcontroller($scope, $http) {         $scope.listing = function() {                     $scope.users = [];                     $http.get('<?php echo site_url('angularjs/get_list'); ?>').success(function($data) {                          $scope.users = $data;                     });                 }     } 

if nest these 2 controllers in markup, can access parent scope functions in child controller. if not, function might not belong controller, service, provider or factory.

<div ng-controller="testcontroller">   <div ng-controller="usercontroller">    </div> </div> 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -