例如,我的HTML只会在弹出窗口中显示
<div id="popup1" style="display: none; width: 600px; height: 400px; overflow: hidden">
<div ng-controller="DataBindingCtrl">
<div rel="title">
Show or Update Image
</div>
<div rel="body" style="padding: 10px; line-height: 150%">
<div >
<img src="https://upload.wikimedia.org/wikipedia/commons/a/ac/No_image_available.svg" style="float: left; background-color: white; width: 250px; height: 320px; border: 1px solid silver; margin: 5px;"/>
</div>
<div class="w2ui-field w2ui-span3">
<label>Files:</label>
<div>
<form class ="form-horizontal">
<input id="file" style="width: 100px" />{{selBookId}}
<input id="currentRecord" type="text" ng-model="currentRecordText" ng-model-instant>
{{currentRecordText}} {{idRec}}
</form>
</div>
</div>
</div>
@*<div rel="buttons">
<button class="btn" onclick="$('#popup2').w2popup()">Switch to Popup 2</button>
</div>*@
</div>
当用户点击弹出窗口按钮时,我想为 idRec 设置一个值。
这是可能的,正确的方法是什么?
答案 0 :(得分:1)
我假设您要从jQuery函数更改范围变量。
您可以在Angular控制器中使用jQuery函数,如下所示。
app.controller('AppCtrl', function($scope) {
$('.popupCall').on('click', function(){
$scope.idRec= "newValue";
$scope.$apply();
$('#popup2').w2popup();
});
}
<button class="btn popupCall">Switch to Popup 2</button>
答案 1 :(得分:0)
您可以做的是在示波器上向控制器添加功能。
DataBindingCtrl
$scope.idRec = '';
$scope.updateIdRec = function() {
$scope.idRec= "newValue";
$('#popup2').w2popup();
};
HTML
<button class="btn" ng-click="updateIdRec()">Switch to Popup 2</button>