简体   繁体   English

将变量传递到html视图angularjs中

[英]pass variable into html view angularjs

I have this code in my angular js controller . 我的角度js控制器中有此代码。

angular.module('IpadAppApp')
    .controller('Mortgage_LoanCtrl', function ($location, $scope, $http, $modal, $sce) {

    var host = 'http://localhost:3000';
    var applicantID;

    $scope.submit_info = function(size) {
    $http.post(url, data, { withCredentials: true, headers: { 'Accept': 'application/javascript', 'Content-Type': 'application/x-www-form-urlencoded;'} })
      .success(function (caseID) {
            var modalInstanceSubmit = $modal.open({
                templateUrl: 'views/mortgage_loan/home_loan_thank_you.html',
                controller: 'Mortgage_LoanCtrl',
                size: size      
                });
                applicantID = caseID;       
        })
  };

   $scope.thank_you_page = function(thank_you_page_data) {
        return $sce.trustAsHtml(thank_you_page_data);
    };

I want to pass the applicantID into my html page 我想将申请人ID传递到我的HTML页面中

<div class="ls-case-id"> Your case ID is:  {{applicantID}} </div>

But it is not passing any data i then tried 但是它没有传递我随后尝试过的任何数据

In my home_loan_thank_you.html 在我的home_loan_thank_you.html中

<p ng-bind-html='thank_you_page(bodyinfo)'></p>

Also passing empty data. 还传递空数据。 So how do i pass applicantID to view or how can i delcare global variables in angularjs controller. 因此,如何传递appenderID进行查看,或者如何在angularjs控制器中delcare全局变量。 I have tried the option of putting above my module or controller declaration and also not putting var in front of the variable name but all to no avail works. 我尝试了将其放在模块或控制器声明上方的选项,也没有将var放在变量名的前面,但全部无济于事。

Thanks 谢谢

If I understand your question correctly, you require variable applicantID to bind with html. 如果我正确理解了您的问题,则您需要使用变量identifierID与html绑定。 In order to bind the variable with html, you should use $scope. 为了将变量与html绑定,应使用$ scope。 So instead of declaring var applicantID ,declare it as a scope variable like $scope.applicantID which will bind the applicantID data to the html 因此,与其声明var ApplicantID而不是声明它为范围变量,如$ scope.applicantID ,它会将ApplicatorID数据绑定到html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM