angularjs - Angular, UI-Router: How do I get access to both a Ctrl and stateParam values within a template? -


based on these set-ups (angular ui-router testing scope inheritance, angular ui-router - how access parameters in nested, named view, passed parent template?), did following (the third holds relevant issue):

  .state("patients", {     url: "/dashboard/patients",     templateurl: 'patients/index.html',     controller: "patientctrl"   })   .state("sharedpatients", {     url: "/dashboard/patients/shared",     templateurl: 'patients/shared_patients.html',     controller: "patientctrl"   })   .state('showpatient', {     url: "/dashboard/patients/:id",     templateurl: 'patients/show.html',     controller: ("patientctrl", ['$scope', '$stateparams', function($scope, $stateparams) {       $scope.patient_id = $stateparams.id;     }])   }) 

patients , sharedpatients work without problem. can go showpatient , access variable patient_id. however, cannot access of functions or variables established in patientctrl. thoughts?

the controller scope inheritance has nothing state inheritance.

your controllers inherit each other if views nested in dom.


also, syntax you're using there misleading. controller: ("patientctrl", [...]) ignore first part. it'll use controller inside array.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -