For the Plunker link referenced, please click here: http://plnkr.co/edit/0vOjw0?p=preview
index.html
<!DOCTYPE html>
<html ng-app="app">
<head>
<link rel="stylesheet" href="style.css">
<script src="angular.min.js?version=1.4.2"></script>
<script src="ui-bootstrap.js"></script>
<script src="script.js"></script>
</head>
<body>
<div class="col-lg-2" style="margin-right: 7px;float: left;">
<button ng-controller="registrationCtrl" type="button" class="btn btn-primary btn-responsive" ng-click="openRegistration()"> Registration</button>
</div>
</body>
</html>
registration.html
<div class="modal-dialog" id="registration.html">
<div class="modal-body">
<form name="form" class="css-form" novalidate>
<label for="pw1">Password:</label>
<input type="password" id="pw1" name="pw1" ng-model="user.pw1" ng-required="" />
<div>{{user.pw1}}</div>
</form>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</div>
</div>
script.js
angular.module('app',['ui.bootstrap']).controller('registrationCtrl', ['$scope','$modal',function ($scope, $modal) {
$scope.openRegistration = function () {
var modalInstance =$modal.open({
templateUrl: 'registration.html',
controller: 'registrationPopupController',
backdrop: 'static',
keyboard: false,
size: 'sm'
});
}
}]).controller('registrationPopupController', ['$location','$scope','$modalInstance',function ($location,$scope,$modalInstance,LoginService) {
$scope.user={
pwd1:''
};
$scope.$watch('user.pwd1',function(newV,oldV){
if(newV!=oldV){
alert(newV)
console.log(newV,oldV);
}
},true);
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
location.href='#/';
};
}]);
The issue I'm encountering is that when I type in the password text box, my $watch function does not trigger in the modal instance controller. However, it works when I type in the same simple controller. Can someone please provide assistance with this?