我的用户界面有两个按钮,一个用于创建,另一个用于编辑。
我在创建和编辑操作中使用了相同的弹出窗口
create_quick_link.html
<div class="row-fluid">
<div class="form-group">
<label class="control-label col-sm-4">
<font class="pull-right">Name</font>
<span class="red pull-right">*</span>
</label>
<input placeholder="Name" type="text" ng-model="quickLink.name">
</div>
<div class="form-group">
<label class="control-label col-sm-4">
<font class="pull-right">URL</font>
<span class="red pull-right">*</span>
</label>
<input placeholder="URL" type="text" ng-model="quickLink.url">
</div>
</div>
$scope.editQuickLink = function (editableQuickLinkdata) {
$scope.quickLink.name = editableQuickLinkdata.quickLinkName;
$scope.quickLink.url = editableQuickLinkdata.quickLinkUrl;
createDialog({
templateUrl: '/app/ajs/followup/app/views/create_quick_link.html',
title: 'Edit Quick Link',
controller: 'FollowupssettingsCtrl',
footerTemplate: '<button class="btn btn-primary" ng-click="updateQuickLink(quickLink)">Update</button>'
});
}
我想设置 editableQuickLinkdata 到 quickLink
我的数据没有填充。我做错了吗?
答案 0 :(得分:4)
您可以按照以下方式执行此操作:
$scope.editQuickLink = function (editableQuickLinkdata) {
createDialog({
templateUrl: '/app/ajs/followup/app/views/create_quick_link.html',
title: 'Edit Quick Link',
controller: 'EditCtrl',
footerTemplate: '<button class="btn btn-primary" ng-click="updateQuickLink(quickLink)">Update</button>'
},{myOldData: editableQuickLinkdata});
}
然后在EditCtrl中,除了$ scope之外,你还会得到myOldData作为参数:
angular.module('MyApp').controller('EditCtrl', ['$scope', 'myOldData',
function($scope, myOldData) {
// Do stuff
}]);