angularjs - Passing variable to uib controller -
i have function takes variable, , want use in controller.
my code looks this
ctrl.openmodal= myitem => { let modal = $uibmodal.open({ templateurl: 'path/to/my/template.html', controller: 'modalcontroller' }); };
problem don't know how access myitem
in controller
module.controller('modalcontroller', function ($scope) { console.log(myitem); });
trying log says undefined.
use resolve
. :
resolve: { myitem : function() { return myitem; } }
then in controller :
module.controller('modalcontroller', function ($scope, myitem) { console.log(myitem); $scope.myitem =myitem;// assign scope variable acces in modal template });
// example modal template:
<script type="text/ng-template" id="template.html"> <div class="modal-header"> <h3 class="modal-title">modal template</h3> </div> <div class="modal-body"> {{ myitem }} </div> </script>
Comments
Post a Comment