Krishna Prasad Ambaripeta Krishna Prasad Ambaripeta - 1 month ago 5
AngularJS Question

View Not Updating After click event from Popup

Confused why is the textbox value not changing to "bbb" after click of the button on the popup.

The jsfiddle is attached.

UI:

<div ng-controller="MyCtrl">
<input type="text" ng-model="test_value"/>
<button ng-click="clickToOpen()">My Modal</button>

<script type="text/ng-template" id="templateId">

<div id="target" ng-click="test1()" ng-controller="MyCtrl">
<input type="button" ng-click="test()" value="Set Data" />
</div>
</script>


Controller:

var myApp = angular.module('myApp',['ngDialog']);

function MyCtrl($scope, ngDialog) {
$scope.test_value = 'aaa';
$scope.clickToOpen = function () {
$scope.dialog = ngDialog.open({ template: 'templateId' , scope : $scope});
};

$scope.test1 = function()
{
$scope.test_value = 'bbb';
console.log($scope.test_value);
$scope.dialog.close();
};
}


http://jsfiddle.net/mb6o4yd1/590/

2ps 2ps
Answer

Change this line

        <div id="target" ng-click="test1()" ng-controller="MyCtrl">
          <input type="button" ng-click="test()" value="Set Data" />
        </div>

to

        <div id="target">
          <input type="button" ng-click="test1()" value="Set Data" />
        </div>

http://jsfiddle.net/vuvxphv3/1/