javascript - How to create Child Controller Angular Js -


define([], function() {     function myctrl($scope,$http)      {         $scope.test = "course man";      }     myctrl.$inject=['$scope','$http'];     return myctrl; }); 

we have separate file each controller , lazy loaded when required.. have corresponding entry in application.js.

now problem :

i need 2-3 child controllers linked parent controller.. , there in single file.. can loaded..


tried :

  define([], function() {         function myctrl($scope,$http)          {             $scope.test = "course man";          }         function myctrl1($scope,$http){};          myctrl.$inject=['$scope','$http'];         return myctrl;     }); 

but, dosen't seems working.

update ----

parent --

 define([], function() {         function myctrl($scope,$http)          {             $scope.test = "course man";          }         myctrl.$inject=['$scope','$http'];         return myctrl;     }); 

with controller :

define([], function() {     function myctrl($scope,$http)      {         $scope.test = "course man";      }     return myctrl; });  function myctrl1($scope,$http){  }; 

this working .. not sure have parent child relationship or not... confused !

you can go other way.

it possible extend controller or make single controller mixin of multiple controllers.

module.controller('ctrlchild', ['$scope', '$controller', function ($scope, $controller) {     // initialize super class , extend it.     angular.extend(this, $controller('ctrlparent', {$scope: $scope}));     … additional extensions create mixin. }]); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -