How can I use input textbox value in the ng-template script tag of same angularjs page

1.3k views Asked by At

I have a email textbox in my angularjs page like this:

<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>

I want to show the email inputed in my ng-dialog. Here is some porion of my ng-dialog script tag:

<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 : [email protected]</p>
  </div>                   
</script>

I want to replace [email protected] in p tag static data with inputed email. How can I do this? Any help? Thanks

Edited

Here is my controller code to invoke 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)
                });
    };
1

There are 1 answers

2
Brendan Green On BEST ANSWER

Update the call to ngDialog.open to include your scope:

ngDialog.open({ template: 'templateId',
    closeByDocument : false,
    preCloseCallback: function(value) {
        $window.location.href="/"
    },
    scope: $scope
});

Now you can reference your model in the dialog:

<p class="margin-v-35-0">Thank ... : {{signUpParams.email}}</p>