Javascript 我无法在我的html页面上显示值,在服务中存储了值,但它不会显示在第二个html页面上

Javascript 我无法在我的html页面上显示值,在服务中存储了值,但它不会显示在第二个html页面上,javascript,angularjs,html,Javascript,Angularjs,Html,这是我的第一个html页面: <form name="createdomain" class="form-horizontal" role="form" ng-controller="domainController"> <swt-tree tree-data="domain.domainName" on-select="statementSelected(branch, selected_branches)" tree-control="statementTree

这是我的第一个html页面:

 <form name="createdomain" class="form-horizontal" role="form" ng-controller="domainController">
     <swt-tree tree-data="domain.domainName" on-select="statementSelected(branch, selected_branches)" tree-control="statementTree" label-provider="rulesLabelProvider" content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
     <!-- This is used for adding a new page as a block to existing page -->
      <button  type="submit" ng-click="addTree(createdomain.$valid)" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">OK</button>
      <button type="submit" ng-click="cancel()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">Cancel</button>
    <div id="ruleEditorContainer" class="ui-layout-container"
        ng-controller="domainController"
        style="height: 95%; width: auto; overflow: hidden;">
    <div class="tab-content">
                                <div class="tab-pane active" id="statements">
                                {{domain.domainName}} <!-- Here I want to display the value which i got from first page -->
                                    <swt-tree tree-data="domain.domainName"
                                        on-select="statementSelected(branch, selected_branches)"
                                        tree-control="statementTree"
                                        label-provider="rulesLabelProvider"
                                        content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
                                </div>
    <div class="tab-pane" id="dictionary">Dictionary will be
                                    shown here</div>
                            </div>
这是我的服务方式:

app.factory('DomainNameService', function() {
    var domainValue=[];
    return{
    addDomain: function(domainName){
        domainValue.push(domainName);
    },
    getDomainName: function(){
        return domainValue;
    }
    }
})
这是我的第二个html页面,我想在其中显示从第一个html页面添加的值:

 <form name="createdomain" class="form-horizontal" role="form" ng-controller="domainController">
     <swt-tree tree-data="domain.domainName" on-select="statementSelected(branch, selected_branches)" tree-control="statementTree" label-provider="rulesLabelProvider" content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
     <!-- This is used for adding a new page as a block to existing page -->
      <button  type="submit" ng-click="addTree(createdomain.$valid)" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">OK</button>
      <button type="submit" ng-click="cancel()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ux_page_button ui-state-hover ui-button-text ui-c ng-binding ng-scope" id="btnData">Cancel</button>
    <div id="ruleEditorContainer" class="ui-layout-container"
        ng-controller="domainController"
        style="height: 95%; width: auto; overflow: hidden;">
    <div class="tab-content">
                                <div class="tab-pane active" id="statements">
                                {{domain.domainName}} <!-- Here I want to display the value which i got from first page -->
                                    <swt-tree tree-data="domain.domainName"
                                        on-select="statementSelected(branch, selected_branches)"
                                        tree-control="statementTree"
                                        label-provider="rulesLabelProvider"
                                        content-provider="rulesContentProvider" expand-level="-1"></swt-tree> 
                                </div>
    <div class="tab-pane" id="dictionary">Dictionary will be
                                    shown here</div>
                            </div>

{{domain.domainName}
这本字典将是
此处显示

我已经在服务中存储了我从第一个html页面获得的值,在控制器中我也从服务方法获得了值,但我无法在第二个html页面上显示该值。请帮我解决这个问题。我真的被卡住了。请提供帮助。

我的猜测是,由于DomainNameService.getDomainName()的输出返回一个数组,因此该输出在HTML中不可见。您可以尝试:$scope.domain.domainName=DomainNameService.getDomainName()[0];尝试了您的解决方案,但仍然无法获取存储在第二个html页面上的值。请找个人帮忙。