【发布时间】:2015-06-05 14:35:44
【问题描述】:
我的 angularjs 页面中有一个电子邮件文本框,如下所示:
<div class="form-group form-control-default required">
<input type="email" class="form-control" ng-model="signUpParams.email" name="email" id="InputEmail1" placeholder="Email" required> </div>
我想显示在我的 ng-dialog 中输入的电子邮件。 这是我的 ng-dialog 脚本标签的一部分:
<script type="text/ng-template" id="templateId">
<div class="media-body act-media-body">
<h5 class="success" style="color:#84b642">Now it is time to complete this process</h5>
<p class="margin-v-35-0">Thank you for signing up for your account. to complete this process you have to confirm by clicking the link we have mailed to your mail account : user@example.com</p>
</div>
</script>
我想用输入的电子邮件替换 p 标签 静态数据中的 user@example.com。 我怎样才能做到这一点?有什么帮助吗?谢谢
已编辑
这是我调用 ng-dialog 的控制器代码:
var loginModule = angular.module('loginModule', ['ngDialog']);
loginModule.controller('loginController', function($scope, $http, $window, ngDialog) {
$scope.signUp = function() {
$http.post("/users/createUser",$scope.signUpParams)
.success(function(response)
{
if(response.status){
if(response.isUserExists){
alert(response.message);
}else if(response.isMailSendSuccessfully){
ngDialog.open({ template: 'templateId',
closeByDocument : false,
preCloseCallback: function(value) {
$window.location.href="/"
}
});
}
}else{
//SOMETHING WENT WRONG
alert(response.message);
}
}).error(function(data, status, headers, config) {
alert(data)
});
};
【问题讨论】:
-
请说明您是如何调用对话框的。您应该能够从当前控制器引用
$scope,然后执行{{signUpParams.email}}。 -
@BrendanGreen,我已经编辑了我的代码。请看
-
试过
{{signUpParams.email}},在脚本标签之外工作,在脚本标签旁边不工作 -
那是因为你需要在 ngDialog open 调用上设置
scope。看我的回答。