从Popup单击事件后查看未更新

时间:2016-10-15 15:30:01

标签: angularjs

混淆为什么文本框值不会更改为" bbb"点击弹出窗口上的按钮后。

附上了jsfiddle。

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>

控制器:

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/

1 个答案:

答案 0 :(得分:0)

更改此行

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

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

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