angularjs - Scope issues in angular modal popup -


i have modal popup on page. modal popup use bootstrap angular library.

inside body of modal have text box ng-model attribute, , on press of ok button want use text box value.

<input type="text" data-ng-model="projectname" class="form-control"  tab-index="1" required /> 

but when log value console, dont value.

$scope.ok = function () {    console.log($scope.projectname);   }; 

i have created plunkr link debugging this. please advice.

you have number of issues. firstly, didn't define scope property on modal. default, scope set child of $rootscope.

 var modalinstance = $modal.open({       templateurl: 'mymodalcontent.html',       controller: modalinstancectrl,       size: size,       scope: $scope,       resolve: {       }     }); 

secondly, should set ng-model property of object, otherwise angular automatically create property on child scope.

controller

var modaldemoctrl = function ($scope, $modal, $log) {   $scope.model = {};    ... } 

markup

<div class="modal-body">     <input type="text" ng-model="model.projectname" /> </div> 

see plunkr working sample: http://plnkr.co/tbvhl27d2pxia19kojob


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -