混淆为什么文本框值不会更改为" 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();
};
}
答案 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>