angularjs - ng-model is not working inside a ui bootstrap modal window and angular -
i'm using modal window using angular , bootstrap ui
<script type="text/ng-template" id="mymodalcontent.html"> <div class="modal-header"> <h3 class="modal-title">cambia palmare {{descpalmare}} ( {{descprogetto}} )</h3> </div> <div class="modal-body"> <ul> <li > <select id="soluzionedlg" name="soluzionedlg" class="required" ng-options="soluzione.id soluzione.denominazione soluzione in soluzioni" ng-model="soluzionecorrente" ng-change="filtrosoluzione()"></select> </li> <select id="progettodlg" name="progettodlg" class="required" ng-options="progetto.id progetto.denominazione progetto in progetti" ng-model="progettocorrente"></select> <li> </li> </ul> </div> <div class="modal-footer"> <button class="btn btn-primary" ng-click="ok()">ok</button> <button class="btn btn-warning" ng-click="cancel()">cancel</button> </div> </script>
i'm opening dialog correctly , soluzionedlg select filled correctly.
when selection changed, filtrosoluzione method correctly called scope variable bound using ng-model undefined.
$scope.filtrosoluzione = () => { alert($scope.soluzionecorrente); var progettopromise = progetti.progettisoluzione($scope.soluzionecorrente); progettopromise.then(function (progetti: factories.progetto[]) { $scope.progetti = progetti; }, function (reason) { alert('errore in recupero lista dispositivi: ' + reason); }, function (update) { alert('got notification: ' + update); }); }
am missing something? used code in other pages , working correctly.
thanks,
luca
this angular code calls $modal.open
// cambia assegnazione, apro la finestra di assegnazione $scope.cambiaassegnazione = (palmare: number) => { var modalinstance = $modal.open({ templateurl: 'mymodalcontent.html', controller: assegnadispispettoredialog, size: '(large)', resolve: { palmaredaaggiornare: function () { return palmare; }, dispositivi: function () { return dispositivi; }, soluzioni: function () { return soluzioni; }, progetti: function () { return progetti; } } }); modalinstance.result.then(function (selecteditem) { $scope.selecteditem = selecteditem; }, function () { alert('modal dismissed at: ' + new date()); }); }
when click link in list mg_chnage change code open dialog: in resolve send reference of few services created, because have fill listbox in modal dialog.
descpalmare, descprogetto , soluzioni scope properties handled correctly: problem in soluzionecorrente member
i created full repro here:
http://plnkr.co/edit/g8qygjwkycqiyzk5fcgn
the modal uses child scope, see understanding scopes in angular.js wiki. try changing ng-model both in page , in modal model.soluzionecorrente
instead , set scope
property of $modal.open
current $scope
.
Comments
Post a Comment